CVE-2017-12598: Out-of-bounds Read in OpenCV

opencv-python Updated 02 Oct 2025

Summary

12/10/2021
Yes i
High
8.8

CVE-2017-12598: Out-of-bounds Read 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-12598 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 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 (Open Source Computer Vision Library) is a popular open-source library used for computer vision and machine learning applications. It provides various functions and algorithms for image and video processing. OpenCV-Python is a Python wrapper for OpenCV, allowing developers to utilize OpenCV functionalities in Python applications. However, OpenCV versions up to 3.3 (including OpenCV-Python 3.3.0.9) are vulnerable to an out-of-bounds read error in the cv::RBaseStream::readBlock function in the modules/imgcodecs/src/bitstrm.cpp file. This vulnerability can be triggered when reading an image file using the cv::imread function.

Vulnerability Detail

The out-of-bounds read vulnerability in OpenCV can lead to potential security risks. An attacker could exploit this vulnerability by providing a specially crafted image file, causing the cv::imread function to read beyond the boundaries of the allocated memory. This can result in the disclosure of sensitive information or a denial of service (DoS) condition. The vulnerability has a CVSS score of 8.8, indicating a high severity level.

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 OpenCV-Python package is not immediately feasible, a possible workaround is to validate the input image file before passing it to the cv::imread function. Developers can implement additional checks to ensure the image file is within the expected boundaries and does not trigger the vulnerability. Here is an example of a workaround in Python:

import cv2

def safe_imread(file_path):
    try:
        img = cv2.imread(file_path)
        # Perform additional validation checks
        # ...
        return img
    except:
        return None

Conclusion

The out-of-bounds read vulnerability in OpenCV can have serious security implications. It is crucial to update the OpenCV-Python package to the fixed version or apply the recommended workaround to mitigate the risk. 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 library that provides computer vision and machine learning algorithms for image and video processing.

The vulnerability in OpenCV can lead to the disclosure of sensitive information or a denial of service (DoS) condition if exploited by an attacker.

To fix this vulnerability, update the OpenCV-Python package to version 3.3.1.11 or higher.

If updating the package is not immediately feasible, a workaround is to validate the input image file before passing it to the cv::imread function.

The CVSS score of this vulnerability is 8.8, indicating a high severity level.

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