Critical Buffer Overflow Vulnerability in Python3 Affects Multiple Alpine Versions
Summary
ALPINE-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 python3 versions < 3.7.7-r2. Fixed in 3.7.7-r2. How to fix ↓
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.
No signup required · Results in about 60 seconds
Background
Python3 is a widely-used programming language known for its simplicity and versatility, enabling developers to create a variety of applications ranging from web development to data analysis. The package in question, python3, is the implementation of Python 3.x for Alpine Linux, a security-oriented, lightweight Linux distribution. This vulnerability poses a significant risk as it allows remote code execution through unsafe handling of floating-point numbers.
Vulnerability Detail
Python 3.x through 3.9.1 contains a buffer overflow vulnerability in the PyCArg_repr function located in _ctypes/callproc.c. This flaw can be exploited by passing untrusted floating-point numbers, such as a 1e300 argument to c_double.from_param, leading to potential remote code execution. The vulnerability arises from the unsafe use of the sprintf function, which can result in memory corruption and arbitrary code execution in affected applications.
How To Fix
Minimum fixed version
3.7.7-r2
This is the first release that contains the fix.
sudo apk add --upgrade python3
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 vulnerable python3 package. Implement input validation to sanitize user inputs before processing them.
Conclusion
The buffer overflow vulnerability in Python3 poses a significant risk to applications running on Alpine Linux. It is crucial for users to update their packages to the patched versions to mitigate potential exploitation. Implementing input validation can serve as a temporary measure until updates are applied.
See every vulnerability recorded for python3 →
FAQ
The CVSS score of this vulnerability is 9.8, indicating a critical level of severity.
Python 3.x versions up to and including 3.9.1 are affected by this vulnerability.
You can use the Vulert playground at Vulert Scanner to check if your application is affected by this vulnerability without needing to sign up.
If an immediate update is not possible, ensure to validate and sanitize all user inputs to mitigate the risk of exploitation.
More information can be found in the CVE database or by visiting the Alpine Linux security advisories.
References
Related vulnerabilities
Recent vulnerabilities recorded for python3.