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

- Severity: Low (CVSS:4.0, scored by GitHub) `CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:N/VC:N/VI:N/VA:L/SC:N/SI:N/SA:N/E:P`
- Known to be exploited: not in CISA's catalogue, which lists only what CISA has confirmed
- Published: 2025-04-01T12:00:00.000Z
- Modified: 2026-09-10T03:50:23.976Z
- Also known as: RUSTSEC-2025-0020
- Weaknesses: CWE-125

## Description

`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.

(As written by GitHub Advisory Database.)

## Affected

- pyo3 (crates.io): from 0.1.0 before 0.24.1; from 0.0.0-0 before 0.24.1

## References

- <https://github.com/PyO3/pyo3/issues/5005> (report, web)
- <https://github.com/PyO3/pyo3/pull/5008> (web)
- <https://github.com/PyO3/pyo3> (package)
- <https://rustsec.org/advisories/RUSTSEC-2025-0020.html> (advisory, web)
- <https://crates.io/crates/pyo3> (package)

## Sources

- GitHub Advisory Database: [GHSA-pph8-gcv7-4qj5](https://github.com/advisories/GHSA-pph8-gcv7-4qj5), CC-BY-4.0, modified 2026-09-10
- RustSec Advisory Database: [RUSTSEC-2025-0020](https://rustsec.org/advisories/RUSTSEC-2025-0020.html), CC0-1.0, modified 2025-10-28

---

Page: https://cve.day/GHSA-pph8-gcv7-4qj5 · Whole record: https://cve.day/GHSA-pph8-gcv7-4qj5.json · Rebuilt by cve.day 2026-11-25T22:56:43.250Z
