SecPod

Learn Search

Search across all Learn content

← Back to Security Research
Uncovering critical vulnerabilities in real-time computer vision library, OpenCV

Uncovering critical vulnerabilities in real-time computer vision library, OpenCV

Jan 6, 2020By Vidita V Koushik4 min read

Artificial intelligence and computer vision fall in the category of top 10 buzzwords of modern day computing. An opensource platform helping industries build a new era of real-time visual processing is OpenCV, a library of programming functions with over 2500 optimized computer vision and machine learning algorithms.

Two< critical vulnerabilities were discovered in OpenCV libraries which allow an attacker to execute arbitrary code. The impact of the exploitation of these vulnerabilities could be huge considering the wide usage of this library in real-time processing applications such as facial recognition technology, robotics, motion tracking, etc. Vulnerability Management Software can prevent such attacks. OpenCV has been adopted by Google, Yahoo, Microsoft, Intel, IBM, Sony, Honda, Toyota, etc. OpenCV has C++, Python, Java and MATLAB interfaces and supports Windows, Linux, Android, and Mac OS.

The vulnerabilities were discovered by Dave McDaniel of Cisco Talos. CVE-2019-5063 and CVE-2019-5064 are buffer overflow vulnerabilities which can be potentially exploited to cause heap corruption and ultimately code execution. Mitigating these vulnerabilities will be easier with a patch management tool.

Delving into the details:
The flaw resides in the data structure persistence functionality of OpenCV, which can be remotely exploited using a crafted XML file(CVE-2019-5063) or a crafted JSON file (CVE-2019-5064) to corrupt the heap structure and cause code execution. These vulnerabilities have been classified as classic buffer overflow (CWE-120), where the program writes data beyond the boundaries of a buffer causing an overflow. The persistence mode functionality in OpenCV allows developers to store and restore various data structures in XML/YAML or JSON format. Arbitrarily complex data structures and primitive data types can also be stored and loaded.

CVE-2019-5063

While parsing an XML file, if an ampersand is encountered, the data till the next semicolon in the XML file is copied into a buffer using memcpy. memcpy is a function which copies data from source to the destination. Here, the size of the buffer is fixed, but, the memcpy size is calculated as the length of the entire XML entity element, where there is no check on the boundary of the buffer.

fig1. buffer overflow during the parsing routine in persistence_xml.cpp

The value of memcpy size is calculated at 1(fig1) and the buffer overflow occurs at 2(fig1). Consider an arrangement where the heap object is located at 0x91c350, the buffer is located at 0x91c380 and the next object in the heap is located at 0x91d390 which is exactly 0x1040 (4160) bytes away.

fig2. heap object corruption in 0x91d390

The size of memcpy exceeds the size of the buffer which leads to an overflow into subsequent heap objects and code execution. This variant of the attack can trigger an access violation as data is copied beyond the heap segment.

CVE-2019-5064

While parsing a JSON file, data is copied until a null byte is encountered. This leads to a buffer overflow as the size of the buffer is not taken into consideration while copying the data and the entire contents of the JSON value field is taken into account for calculating memcpy size.


fig3. buffer overflow during the parsing routine in persistence_json.cpp

The value of memcpy size is calculated at 1(fig3) and the buffer overflow occurs at 2(fig3). Consider an arrangement where the heap object is located at 0x91c350, the buffer is located at 0x91c380 and the next object in the heap is located at 0x91d780 which is exactly 0x1400 (5120) bytes away.


fig4. heap object corruption in 0x91d780

The size of memcpy exceeds the size of the buffer which leads to an overflow into subsequent heap objects and code execution. This variant of the attack can trigger an arbitrary free() if it is allowed to run continuously.

Affected Products
OpenCV version 4.1.0

Impact

An attacker can use a specially crafted JSON or an XML file to overflow the buffer and execute malicious code on the affected system.

Solution

OpenCV has released updates to fix the vulnerabilities. Please upgrade to version 4.2.0 at the earliest.

Featured Posts

Open GT13 Campaign Targets 22 Organizations Through Check Point Security Management Server Exploitation
GT13 Campaign Targets 22 Organizations Through Check Point Security Management Server Exploitation

CVE Research

GT13 Campaign Targets 22 Organizations Through Check Point Security Management Server Exploitation

The GT13 campaign targeted at least 22 organizations worldwide by exploiting vulnerabilities in exposed services and Check Point Security Management Servers. The attackers used forged authentication sessions, SSH-based persistence, internal reconnaissance, lateral movement, and data exfiltration techniques to compromise systems and access sensitive information.

Nov 26, 2026

Open GeoServer Flaws Under Attack: Inside the Exploit Chain to Remote Code Execution
vulnerability researchGeoServer Flaws Under Attack: Inside the Exploit Chain to Remote Code Execution

CVE Research

GeoServer Flaws Under Attack: Inside the Exploit Chain to Remote Code Execution

Six vulnerabilities in GeoServer’s November 2026 security update can expose sensitive files, bypass service authorization, and enable administrator impersonation. Several of these flaws can be chained for unauthenticated remote code execution with the permissions of the GeoServer process. CVE-2026-120705 and CVE-2026-129243 have been reported as exploited. Fixed releases include GeoServer 3.0.2, 2.28.6, and 2.27.7. This article covers the flaws, the public five-CVE chain, impact, affected versions, and remediation guidance.

Nov 26, 2026

Open Critical Security Flaws in Microsoft Office, Erlang/OTP and Mozilla Thunderbird: November 25, 2026
Critical Security Flaws in Microsoft Office, Erlang/OTP and Mozilla Thunderbird: November 25, 2026

CVE Research

Critical Security Flaws in Microsoft Office, Erlang/OTP and Mozilla Thunderbird: November 25, 2026

Critical security flaws disclosed in November 2026 affect Microsoft Office, Erlang/OTP, and Mozilla Thunderbird. Explore CVE-2026-112732, CVE-2026-124286, and CVE-2026-136226, including remote code execution, TLS server impersonation, email spoofing risks, affected versions, and fixes.

Nov 25, 2026

Open Critical Vulnerabilities, November 23, 2026: Ruby2Shell in GitLab CE/EE and Seven rclone Flaws
vulnerability researchCritical Vulnerabilities, November 23, 2026: Ruby2Shell in GitLab CE/EE and Seven rclone Flaws

CVE Research

Critical Vulnerabilities, November 23, 2026: Ruby2Shell in GitLab CE/EE and Seven rclone Flaws

Nov 24, 2026