ctypes: Buffer overflow in PyCArg_repr

Warning

This resource is maintained for historical reference and does not contain the latest vulnerability info for Python.

The canonical database for vulnerabilities affecting Python is available on GitHub in the Open Source Vulnerability (OSV) format. This vulnerability can be viewed online at the Open Source Vulnerability Database.

There’s a buffer overflow in the ctypes PyCArg_repr() function.

Dates:

  • Disclosure date: 2021-01-16 (Python issue bpo-42938 reported)

Fixed In

Python issue

[security][CVE-2021-3177] ctypes double representation BoF.

  • Python issue: bpo-42938
  • Creation date: 2021-01-16
  • Reporter: Jordy Zomer

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 demonstrated by a 1e300 argument to c_double.from_param. This occurs because sprintf is used unsafely.

Timeline

Timeline using the disclosure date 2021-01-16 as reference: