CVE-2017-12601: Buffer Overflow in OpenCV-Python
Summary
CVE-2017-12601: Improper Restriction of Operations within the Bounds of a Memory Buffer in OpenCV. Affects opencv-python versions < 3.3.1.11. Fixed in 3.3.1.11. How to fix ↓
Also tracked for
- opencv-contrib-python · PyPI
- opencv · Debian:11
The same CVE-2017-12601 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 (Open Source Computer Vision Library) is a popular open-source computer vision and machine learning software library. It provides various functions and algorithms for image and video processing, object detection, and more. OpenCV-Python is a Python wrapper for OpenCV, allowing developers to use OpenCV functionalities in Python applications. However, OpenCV-Python versions up to 3.3.0.9 are vulnerable to a buffer overflow.
Vulnerability Detail
The vulnerability, identified as CVE-2017-12601, is an improper restriction of operations within the bounds of a memory buffer in OpenCV. It specifically affects the cv::BmpDecoder::readData function in the modules/imgcodecs/src/grfmt_bmp.cpp file. When reading an image file using cv::imread, an attacker can exploit this vulnerability to trigger a buffer overflow. This can lead to arbitrary code execution, denial of service, or information disclosure.
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.3.1.11
This is the first release that contains the fix.
pip install --upgrade "opencv-python==3.3.1.11"
Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →
Workaround
If updating the package is not immediately feasible, developers can implement input validation and boundary checks when using the cv::imread function. By ensuring that the image file size and format are within expected limits, the risk of triggering the buffer overflow can be mitigated. Here's an example of how to perform input validation in Python:
import cv2
def read_image_safely(file_path):
max_file_size = 10 * 1024 * 1024 # Maximum allowed file size in bytes
try:
file_size = os.path.getsize(file_path)
if file_size > max_file_size:
raise ValueError('File size exceeds the maximum allowed limit.')
image = cv2.imread(file_path)
return image
except Exception as e:
print('Error reading image:', str(e))
return None
Conclusion
The buffer overflow vulnerability in OpenCV-Python versions up to 3.3.0.9 can have severe consequences, including arbitrary code execution, denial of service, or information disclosure. It is crucial to update the OpenCV-Python package to version 3.3.1.11 or higher to mitigate this vulnerability. If immediate updating is not possible, implementing input validation and boundary checks can provide temporary mitigation. For further assistance and support in vulnerability remediation, please contact DevNack.com.
See every vulnerability recorded for opencv-python →
FAQ
OpenCV (Open Source Computer Vision Library) is an open-source computer vision and machine learning software library. It provides various functions and algorithms for image and video processing, object detection, and more.
OpenCV-Python is a Python wrapper for OpenCV, allowing developers to use OpenCV functionalities in Python applications.
The vulnerability can be exploited by an attacker to trigger a buffer overflow, potentially leading to arbitrary code execution, denial of service, or information disclosure.
To fix this vulnerability, update the OpenCV-Python package to version 3.3.1.11 or higher using the command 'pip install --upgrade opencv-python'.
If updating the package is not immediately feasible, developers can implement input validation and boundary checks when using the cv::imread function to mitigate the risk of triggering the buffer overflow.
References
Related vulnerabilities
Recent vulnerabilities recorded for opencv-python.