Buffer Overflow Vulnerability in Python Packages: python2.7 and python3.9

python2.7 Updated 02 Oct 2025

Summary

19/01/2021
N/A
Yes i
Unrated
Not published

DEBIAN-CVE-2021-3177: Python 3.x through 3.9.1 has a buffer overflow in PyCArg_repr in _ctypes/callproc.c, which may lead to remote code execution in certain Python applications that accept floating-point numbers as untrusted input, as demons... Affects python2.7 versions < 2.7.18-2. Fixed in 2.7.18-2. 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 widely-used high-level programming language known for its readability and versatility. The affected packages, python2.7 and python3.9, are implementations of the Python programming language. They are used in various applications for scripting, automation, data analysis, and web development. This vulnerability affects how these packages handle floating-point numbers, potentially leading to severe security risks.

Vulnerability Detail

Python 3.x through 3.9.1 has a buffer overflow in the PyCArg_repr function located in _ctypes/callproc.c. This vulnerability can lead to remote code execution in certain Python applications that accept untrusted floating-point input. An example of this is passing a 1e300 argument to c_double.from_param, which can exploit the unsafe use of sprintf, allowing attackers to execute arbitrary code.

How To Fix

Minimum fixed version

2.7.18-2

This is the first release that contains the fix.

sudo apt-get install --only-upgrade python2.7

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

Workaround

As a temporary workaround, avoid using untrusted floating-point inputs in applications that utilize the affected Python versions. Implement input validation to ensure that only safe and expected values are processed.

Conclusion

The buffer overflow vulnerability in Python packages python2.7 and python3.9 poses significant security risks, particularly in applications that handle untrusted floating-point inputs. It is crucial to update to the patched versions to mitigate these risks and ensure the security of your applications.

See every vulnerability recorded for python2.7 →

Share this vulnerability

FAQ

A buffer overflow occurs when a program writes more data to a buffer than it can hold, potentially overwriting adjacent memory and leading to unpredictable behavior or security vulnerabilities.

An attacker can exploit this vulnerability by providing specially crafted floating-point numbers as input, which may lead to arbitrary code execution within the affected application.

The vulnerability affects Python 3.x versions up to and including 3.9.1, as well as Python 2.7 versions prior to the fixed release.

Yes, you can use Vulert, which monitors open-source vulnerabilities in your software. By uploading a manifest file like package-lock.json, you can check for vulnerabilities in real-time without needing to install any software.

If immediate updates are not possible, ensure that your applications do not accept untrusted floating-point inputs and implement strict input validation as a temporary measure.

Related vulnerabilities

Recent vulnerabilities recorded for python2.7.

How To Fix

Minimum fixed version

2.7.18-2

This is the first release that contains the fix.

sudo apt-get install --only-upgrade python2.7

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