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 Critical RabbitMQ OAuth2 Authentication Bypass Could Grant Admin Access: November 30, 2026
Critical RabbitMQ OAuth2 Authentication Bypass Could Grant Admin Access: November 30, 2026

CVE Research

Critical RabbitMQ OAuth2 Authentication Bypass Could Grant Admin Access: November 30, 2026

A critical RabbitMQ OAuth2 vulnerability rated 9.1 allows unauthorized privileged token issuance in affected management configurations. Explore technical analysis, security risks, affected versions, exploitation evidence, available security patches and recommended remediation strategies.

Dec 1, 2026

Open Critical Vulnerabilities in MySQL Server, MySQL Cluster and RealVNC - November 30, 2026
Critical Vulnerabilities in MySQL Server, MySQL Cluster and RealVNC - November 30, 2026

CVE Research

Critical Vulnerabilities in MySQL Server, MySQL Cluster and RealVNC - November 30, 2026

Explore two Critical vulnerabilities affecting MySQL Server, MySQL Cluster and RealVNC, involving improper authentication and out-of-bounds write weaknesses. Understand their technical root causes, affected versions, CVSS severity, exploitation evidence, security patches and recommended remediation strategies.

Nov 30, 2026

Open November 2026 Linux Security Updates for Debian, Fedora, Red Hat and Ubuntu: Critical Browser, .NET and Enterprise Infrastructure Vulnerabilities
November 2026 Linux Security Updates for Debian, Fedora, Red Hat and Ubuntu: Critical Browser, .NET and Enterprise Infrastructure Vulnerabilities

CVE Research

November 2026 Linux Security Updates for Debian, Fedora, Red Hat and Ubuntu: Critical Browser, .NET and Enterprise Infrastructure Vulnerabilities

Nov 27, 2026

Open Linux Vulnerability Research: Critical PHP, Chromium and Kernel Security Updates – November 25, 2026
Linux Vulnerability Research: Critical PHP, Chromium and Kernel Security Updates – November 25, 2026

CVE Research

Linux Vulnerability Research: Critical PHP, Chromium and Kernel Security Updates – November 25, 2026

Explore 20 Linux security advisories across Debian, Fedora, Red Hat and Rocky Linux, covering Critical PHP and Chromium vulnerabilities, kernel security flaws, known exploitation evidence, technical vulnerability analysis, security patches and recommended remediation strategies.

Nov 27, 2026