CVE-2017-12601: Buffer Overflow in OpenCV-Python

opencv-python Updated 02 Oct 2025

Summary

12/10/2021
Yes i
High
8.8

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

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.

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

Sponsored MarkAI Find prospects already talking about the problem you solve AI watches the communities your customers use to find qualified prospects, then alerts you when a conversation is worth joining. See MarkAI

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 →

Share this vulnerability

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.

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.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 →

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