CVE-2018-5268: Out-of-bounds Write in OpenCV

opencv-python Updated 02 Oct 2025

Summary

12/10/2021
Yes i
Moderate
5.5

CVE-2018-5268: Out-of-bounds Write in OpenCV. Affects opencv-python versions < 3.4.1.15. Fixed in 3.4.1.15. How to fix ↓

Also tracked for

The same CVE-2018-5268 is tracked separately for each ecosystem and vendor. Its fix information is the same; the package and affected versions differ.

Free scan

Check if this vulnerability affects your application

Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.

Check my app free

No signup required · Results in about 60 seconds

Upload your dependency manifest or SBOM

Drag & drop your file here or

Java Javascript PHP Python Go Rust Ruby Dart C/C++ Elixir CycloneDX SPDX

Upload a supported dependency manifest or SBOM. No installation or source-code access required.

See supported files and SBOM formats
SBOM sbom.json · bom.json · bom.xml · *.spdx.json · *.cdx.json · *.cdx.xml
Java pom.xml · gradle.lockfile · buildscript-gradle.lockfile
Javascript package-lock.json · yarn.lock · pnpm-lock.yaml
PHP composer.lock
Python poetry.lock · requirements.txt · Pipfile.lock
Go go.mod
Rust Cargo.lock
Ruby Gemfile.lock
Dart pubspec.lock
C/C++ conan.lock
Elixir mix.lock
Enter your work email to receive your report link.

Verify your email to view the full report and start 30 days of continuous monitoring. No credit card required.

Sponsored Devnack Penetration testing for web, API and mobile Manual testing by engineers who build software, not an auditor's checklist. Trusted by teams at Swift and Google Talk to Devnack

Background

OpenCV is an open-source computer vision library widely used for image and video processing. It provides various functions and algorithms for tasks such as object detection, image recognition, and video analysis. OpenCV-Python is a Python wrapper for OpenCV, allowing developers to utilize OpenCV functionalities in Python applications. However, OpenCV-Python versions up to 3.3.1.11 are vulnerable to an out-of-bounds write vulnerability.

Vulnerability Detail

The vulnerability (CVE-2018-5268) in OpenCV-Python arises from a heap-based buffer overflow in the cv::Jpeg2KDecoder::readComponent8u function in the grfmt_jpeg2000.cpp file of the imgcodecs module. This vulnerability can be exploited by parsing a specially crafted image file. An attacker could potentially execute arbitrary code or cause a denial-of-service (DoS) condition by exploiting this vulnerability.

How To Fix

Latest published version: 5.0.0.93 as of 23 Oct 2026

pip install --upgrade "opencv-python==5.0.0.93"

Upgrading to it may include breaking changes; the version below is the minimum fixed release for this vulnerability.

If you need the minimum change

3.4.1.15

This is the first release that contains the fix.

pip install --upgrade "opencv-python==3.4.1.15"

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Workaround

As a workaround, users can avoid parsing untrusted or unknown image files using OpenCV-Python until the package is updated to a secure version. Additionally, implementing proper input validation and sanitization in the application can help mitigate the risk of exploitation.

Conclusion

The out-of-bounds write vulnerability in OpenCV-Python (CVE-2018-5268) can be mitigated by updating to version 3.4.1.15 or later. It is important to promptly apply the recommended fix to ensure the security and stability of applications utilizing OpenCV-Python. For further support and assistance in vulnerability remediation, please contact DevNack.com.

See every vulnerability recorded for opencv-python →

Share this vulnerability

FAQ

OpenCV is an open-source computer vision library used for image and video processing tasks.

OpenCV-Python is a Python wrapper for OpenCV, allowing developers to use OpenCV functionalities in Python applications.

This vulnerability can potentially allow an attacker to execute arbitrary code or cause a denial-of-service condition by exploiting the heap-based buffer overflow.

To fix this vulnerability, update OpenCV-Python to version 3.4.1.15 or later using the 'pip install --upgrade opencv-python' command.

As a workaround, avoid parsing untrusted or unknown image files using OpenCV-Python until the package is updated. Implementing proper input validation and sanitization can also help mitigate the risk.

Related vulnerabilities

Recent vulnerabilities recorded for opencv-python.

How To Fix

Latest published version: 5.0.0.93 as of 23 Oct 2026

pip install --upgrade "opencv-python==5.0.0.93"

Upgrading to it may include breaking changes; the version below is the minimum fixed release for this vulnerability.

If you need the minimum change

3.4.1.15

This is the first release that contains the fix.

pip install --upgrade "opencv-python==3.4.1.15"

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Subscribe to Vulert on Telegram
Daily digest of new CVEs, critical and high severity, affected packages and fixes — plus a weekly roundup.
Join the channel →
Help improve this record
Report an issue or send feedback