Buffer Overflow Vulnerability in OpenCV Package: CVE-2017-12862

opencv Updated 02 Oct 2025

Summary

15/08/2017
N/A
Yes i
High
8.8

CVE-2017-12862: In modules/imgcodecs/src/grfmt_pxm.cpp, the length of buffer AutoBuffer _src is small than expected, which will cause copy buffer overflow later. Affects opencv across 3 version ranges.

< 2a9d1b22ed76eb22fad1a5edf6faf4d05f207b13 < 3.2.0+dfsg-6 < e8357c0544c82beda237defc0abc90ee28992ee7

Fixed in 3.2.0+dfsg-6. How to fix ↓

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 and machine learning software library that provides a common infrastructure for computer vision applications. It is widely used for real-time image processing and analysis. The library supports various programming languages and is known for its efficiency and ease of use. However, versions 3.3 and earlier of OpenCV are susceptible to a critical buffer overflow vulnerability, which can lead to severe security risks.

Vulnerability Detail

The vulnerability identified as CVE-2017-12862 arises from a flaw in the imgcodecs module, specifically in the grfmt_pxm.cpp file. The issue is caused by the length of the AutoBuffer _src being smaller than expected, leading to a buffer overflow during a copy operation. If an attacker sends a specially crafted image from a remote location, it could result in remote code execution or denial of service. This vulnerability affects OpenCV versions 3.3 and earlier, posing a significant risk to applications relying on these versions.

How To Fix

Minimum fixed version

3.2.0+dfsg-6

This is the first release that contains the fix.

sudo apt-get install --only-upgrade opencv

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

Workaround

As a temporary measure, users can avoid processing images from untrusted sources to mitigate the risk of exploitation until they can upgrade to a secure version of OpenCV.

Conclusion

CVE-2017-12862 is a critical vulnerability in OpenCV that can lead to severe security risks if not addressed. Users are strongly advised to upgrade to a secure version of the library to protect their applications from potential exploitation. Utilizing tools like Vulert can help monitor and alert for such vulnerabilities in real-time.

See every vulnerability recorded for opencv →

Share this vulnerability

FAQ

CVE-2017-12862 is a buffer overflow vulnerability in OpenCV that can lead to remote code execution or denial of service.

OpenCV versions 3.3 and earlier are affected by this vulnerability.

You can use Vulert, which monitors open-source vulnerabilities in your software. Simply upload your manifest file like package-lock.json to check for vulnerabilities.

The CVSS score for CVE-2017-12862 is 8.8, indicating a high severity level.

If immediate upgrading is not possible, avoid processing images from untrusted sources as a temporary workaround.

Related vulnerabilities

Recent vulnerabilities recorded for opencv.

How To Fix

Minimum fixed version

3.2.0+dfsg-6

This is the first release that contains the fix.

sudo apt-get install --only-upgrade opencv

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