Advisory Database
  • Advisories
  • Dependency Scanning
  1. cargo
  2. ›
  3. pyo3
  4. ›
  5. GHSA-pph8-gcv7-4qj5

GHSA-pph8-gcv7-4qj5: PyO3 Risk of buffer overflow in `PyString::from_object`

April 2, 2025

PyString::from_object took &str arguments and forwarded them directly to the Python C API without checking for terminating nul bytes. This could lead the Python interpreter to read beyond the end of the &str data and potentially leak contents of the out-of-bounds read (by raising a Python exception containing a copy of the data including the overflow).

In PyO3 0.24.1 this function will now allocate a CString to guarantee a terminating nul bytes. PyO3 0.25 will likely offer an alternative API which takes &CStr arguments.

References

  • github.com/PyO3/pyo3
  • github.com/PyO3/pyo3/issues/5005
  • github.com/PyO3/pyo3/pull/5008
  • github.com/advisories/GHSA-pph8-gcv7-4qj5
  • rustsec.org/advisories/RUSTSEC-2025-0020.html

Code Behaviors & Features

Detect and mitigate GHSA-pph8-gcv7-4qj5 with GitLab Dependency Scanning

Secure your software supply chain by verifying that all open source dependencies used in your projects contain no disclosed vulnerabilities. Learn more about Dependency Scanning →

Affected versions

All versions starting from 0.1.0 before 0.24.1

Fixed versions

  • 0.24.1

Solution

Upgrade to version 0.24.1 or above.

Weakness

  • CWE-125: Out-of-bounds Read

Source file

cargo/pyo3/GHSA-pph8-gcv7-4qj5.yml

Spotted a mistake? Edit the file on GitLab.

  • Site Repo
  • About GitLab
  • Terms
  • Privacy Statement
  • Contact

Page generated Wed, 14 May 2025 12:15:28 +0000.