PSF-2021-3: 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 most exposed to this issue?
Python applications using affected Python 3.x releases through 3.9.1 are exposed when they accept floating-point values from untrusted input in a path that reaches ctypes argument handling. The described proof of concept uses a 1e300 value passed to c_double.from_param.
How can I determine whether an application may be affected?
Check whether it runs Python 3.x through 3.9.1 and accepts attacker-controlled floating-point input. Prioritize code that uses ctypes and passes such values through c_double.from_param or related ctypes call paths.