Skip to content
Memory corruption Advisory Advanced CVE-2019-5063

OpenCV XML Persistence Parser Buffer Overflow Vulnerability

A heap buffer overflow exists in OpenCV's XML persistence parser when handling a long character entity reference. An attacker could provide a crafted XML file to cause heap corruption and potentially achieve code execution.

Dave McDaniel Follow

Originally disclosed on Cisco Talos

High 8.8 View original

An exploitable heap buffer overflow vulnerability exists in the data structure persistence functionality of OpenCV 4.1.0. A specially crafted XML file can cause a buffer overflow, resulting in multiple heap corruptions and potential code execution.

Dave McDaniel, on Cisco Talos

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

The parser copies an XML entity reference into a fixed-size buffer without checking its length, leading to a heap overflow.

Impact

The overflow corrupts heap memory and can lead to code execution, though in the demonstrated case it caused a segmentation fault.

What the attacker needed

Victim opens a crafted XML file

The fix

The vulnerability was fixed by the vendor in December 2019.

How it was found

  1. Create an XML file containing a long character entity reference.
  2. Load the file using OpenCV's FileStorage in read mode.
  3. The parser copies the entity into a fixed-size buffer, causing a heap overflow.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

OpenCV is a library for computer vision tasks. It can save and load data in XML files. A bug in how it reads certain characters from XML files allows an attacker to write more data than the buffer can hold, corrupting memory and possibly running malicious code.

What is Memory corruption?

Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.

More by Dave McDaniel

View all

23 more disclosed reports, best first.

More from Cisco Talos

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Memory corruption

The lesson behind this report.

Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.