VYPR
Moderate severityNVD Advisory· Published Jan 8, 2018· Updated Aug 5, 2024

CVE-2018-5268

CVE-2018-5268

Description

In OpenCV 3.3.1, a heap-based buffer overflow happens in cv::Jpeg2KDecoder::readComponent8u in modules/imgcodecs/src/grfmt_jpeg2000.cpp when parsing a crafted image file.

AI Insight

LLM-synthesized narrative grounded in this CVE's description and references.

A heap-based buffer overflow in OpenCV 3.3.1's Jpeg2KDecoder when parsing crafted JPEG2000 images can lead to denial of service or potential code execution.

Vulnerability

A heap-based buffer overflow exists in cv::Jpeg2KDecoder::readComponent8u in modules/imgcodecs/src/grfmt_jpeg2000.cpp of OpenCV 3.3.1 [4]. The vulnerability occurs when the function decodes a crafted JPEG2000 image without properly validating component data, leading to an out-of-bounds write. The issue was reported in OpenCV issue #10541 [4] and addressed in a subsequent fix [2].

Exploitation

An attacker can exploit this flaw by supplying a specially crafted JPEG2000 image file to an application that uses OpenCV's imread() or similar decoding functions. No authentication or special privileges are required; the attack can be remote if the victim opens the malicious image from an untrusted source. The overflow is triggered during the readComponent8u function when a component data type mismatch causes a write past the end of the allocated heap buffer [4].

Impact

Successful exploitation corrupts heap memory, which typically results in a denial-of-service (application crash). Under favorable conditions, the attacker may achieve arbitrary code execution with the privileges of the process. The AddressSanitizer trace in the issue report [4] confirms a 1-byte write overflow adjacent to a 6-byte allocation, confirming the heap buffer overflow nature of the flaw.

Mitigation

The fix was committed to OpenCV's master branch via pull request #10566 [2] and is included in OpenCV versions starting from 3.4. Users should upgrade to OpenCV 3.4 or later. For installations running version 3.3.1 or earlier where an upgrade is not possible, avoid processing JPEG2000 images from untrusted sources. No other workaround is available in the affected version.

AI Insight generated on May 22, 2026. Synthesized from this CVE's description and the cited reference URLs; citations are validated against the source bundle.

Affected packages

Versions sourced from the GitHub Security Advisory.

PackageAffected versionsPatched versions
opencv-pythonPyPI
< 3.4.1.153.4.1.15
opencv-contrib-pythonPyPI
< 3.4.1.153.4.1.15

Affected products

2

Patches

0

No patches discovered yet.

Vulnerability mechanics

AI mechanics synthesis has not run for this CVE yet.

References

8

News mentions

0

No linked articles in our index yet.