CVE-2018-5268: Out-of-bounds Write in OpenCV
Summary
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
- opencv-contrib-python · PyPI
- opencv · Debian:11
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.
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.
No signup required · Results in about 60 seconds
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 →
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.
References
Related vulnerabilities
Recent vulnerabilities recorded for opencv-python.