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 Silent Lynx Hits CIS Governments With WinRAR Flaw
threat intelligenceSilent Lynx Hits CIS Governments With WinRAR Flaw

CVE Research

Silent Lynx Hits CIS Governments With WinRAR Flaw

Silent Lynx (UAT-6275 / TAG-193) is a cyber-espionage actor targeting government organizations across the Commonwealth of Independent States. From June 2025 through August 2026, the group used four infection chains, including macro-enabled documents, PS2EXE downloaders, LNK-based PowerShell loaders, and WinRAR archives that exploit CVE-2025-8088, to deploy custom reverse shells such as FoalShell, Chvost, Laplas, and PickleShell. Activity spans nine countries and focuses on diplomacy, economic development, environmental management, water resources, and energy. This article summarizes the campaign’s delivery methods, infrastructure exposure, indicators of compromise, and practical mitigations for defenders.

Oct 16, 2026

Open Drupal Fixes Critical Field UI Flaw Linked to Remote Code Execution
Drupal Fixes Critical Field UI Flaw Linked to Remote Code Execution

CVE Research

Drupal Fixes Critical Field UI Flaw Linked to Remote Code Execution

A critical vulnerability in Drupal core's Field UI module could allow attackers to execute arbitrary code on vulnerable websites through exposed contributed modules or custom code. Tracked as CVE-2026-108097, the flaw stems from improper validation of PHP callbacks during table rendering. At least one known exploitation path does not require authentication, potentially putting affected websites at risk of server compromise.

Oct 16, 2026

Open Palo Alto PAN-OS Vulnerability CVE-2026-0322 Could Allow Root-Level Code Execution
vulnerability researchPalo Alto PAN-OS Vulnerability CVE-2026-0322 Could Allow Root-Level Code Execution

CVE Research

Palo Alto PAN-OS Vulnerability CVE-2026-0322 Could Allow Root-Level Code Execution

Oct 15, 2026

Open Cisco Secure Email Gateway Under Attack: Critical CVE-2026-76519 Enables Arbitrary File Write
vulnerability researchCisco Secure Email Gateway Under Attack: Critical CVE-2026-76519 Enables Arbitrary File Write

CVE Research

Cisco Secure Email Gateway Under Attack: Critical CVE-2026-76519 Enables Arbitrary File Write

Oct 15, 2026