BIT-python-2021-3177: Buffer Overflow
Python 3.x through 3.9.1 has a buffer overflow in PyCArgrepr in ctypes/callproc.c, which may lead to remote code execution in certain Python applications that accept floating-point numbers as untrusted input, as demonstrated by a 1e300 argument to cdouble.fromparam. This occurs because sprintf is used unsafely.
Affected Software
Event History
Frequently Asked Questions
Which applications are realistically exposed?
Exposure is limited to certain Python applications that accept floating-point values from untrusted input and pass them through the affected ctypes path. The issue affects Python 3.x through 3.9.1, but the provided information does not establish that every application using those versions is exploitable.
What would an attacker need to provide to trigger the issue?
An attacker would need to supply a floating-point value as untrusted input in an application that reaches c_double.from_param. A very large value such as 1e300 is identified as an example that can demonstrate the overflow.