BIT-libpython-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 deployments are most exposed?
Python applications that accept floating-point values from untrusted sources are the relevant exposure scenario, particularly where those values reach ctypes handling.
What does exploitation require?
The described attack is network-reachable, requires no privileges or user interaction, and can be triggered with an untrusted floating-point input. A 1e300 argument passed to c_double.from_param is given as an example.
How can I determine whether a system is affected?
Check whether it uses Python 3.x through 3.9.1. Then identify application paths where untrusted floating-point input may be passed to c_double.from_param or related ctypes processing.