Integer Overflow Vulnerability in Python

python Updated 02 Oct 2025

Summary

17/11/2017
N/A
Yes i
Critical
9.8

CVE-2017-1000158: CPython (aka Python) up to 2.7.13 is vulnerable to an integer overflow in the PyString_DecodeEscape function in stringobject.c, resulting in heap-based buffer overflow (and possible arbitrary code execution). Affects python across 2 version ranges.

< 2.7.14-r0 < ca079a3ea30098aff3197c559a0e32d42dda6d84

Fixed in 2.7.14-r0. 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 Your last release was probably never penetration tested Manual testing by engineers who build software, not an auditor's checklist. Trusted by teams at Swift and Google Talk to Devnack

Background

Python is a popular programming language known for its simplicity and readability. It is widely used for various applications, including web development, data analysis, and artificial intelligence. The vulnerability, identified as CVE-2017-1000158, affects CPython (Python) versions up to 2.7.13. It is an integer overflow vulnerability in the PyString_DecodeEscape function in stringobject.c, leading to a heap-based buffer overflow and potential arbitrary code execution.

Vulnerability Detail

The integer overflow vulnerability in Python arises due to a flaw in the PyString_DecodeEscape function. By exploiting this vulnerability, an attacker can trigger a heap-based buffer overflow, potentially allowing them to execute arbitrary code on the affected system. This can lead to various consequences, including remote code execution, privilege escalation, and unauthorized access to sensitive information.

How To Fix

Minimum fixed version

2.7.14-r0

This is the first release that contains the fix.

sudo apk add --upgrade python

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

Workaround

If immediate updating is not feasible, a temporary workaround is to avoid processing untrusted input using the PyString_DecodeEscape function. By refraining from utilizing this specific function, the risk of triggering the vulnerability can be mitigated. However, this workaround should only be considered as a temporary solution, and updating to the patched version is strongly recommended.

Conclusion

The integer overflow vulnerability in Python (CVE-2017-1000158) poses a significant risk to systems running affected versions. It is crucial to update Python to version 2.7.14-r0 or later to mitigate the vulnerability. By doing so, users can protect their systems from potential arbitrary code execution and other security risks. For further support and assistance in vulnerability remediation, please contact DevNack.com.

See every vulnerability recorded for python →

Share this vulnerability

FAQ

The vulnerability can potentially allow an attacker to execute arbitrary code on the affected system, leading to various consequences such as remote code execution, privilege escalation, and unauthorized access to sensitive information.

The vulnerability affects Python versions up to 2.7.13.

You can use the Vulert Playground at Vulert Scanner to check if your Python installation is affected by this vulnerability. Simply upload your package-lock.json file to the playground, and it will provide real-time monitoring and alerts for open-source vulnerabilities.

Yes, the CVSS score for this vulnerability is 9.8, indicating a critical severity level.

At the time of this report, there are no known public exploits specifically targeting this vulnerability. However, it is crucial to update Python to the patched version to prevent potential exploitation.

Related vulnerabilities

Recent vulnerabilities recorded for python.

How To Fix

Minimum fixed version

2.7.14-r0

This is the first release that contains the fix.

sudo apk add --upgrade python

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