{"id":"GHSA-pph8-gcv7-4qj5","aliases":["GHSA-pph8-gcv7-4qj5","RUSTSEC-2025-0020"],"related":[],"kind":"vulnerability","state":"published","title":"PyO3 Risk of buffer overflow in `PyString::from_object`","summary":"`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).\n\nIn 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.","summaryFormat":"markdown","summarySource":"ghsa","descriptions":[{"lang":"en","text":"`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).\n\nIn 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.","format":"markdown","source":"ghsa"}],"published":"2025-04-01T12:00:00.000Z","modified":"2026-09-10T03:50:23.976Z","severity":{"scorer":"GitHub","scheme":"CVSS:4.0","vector":"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","rating":"LOW"},"severities":[{"scorer":"GitHub","scheme":"CVSS:4.0","vector":"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","rating":"LOW"}],"cwes":["CWE-125"],"affected":[{"ranges":[{"type":"semver","introduced":"0.1.0","status":"affected","fixed":"0.24.1"}],"ecosystem":"crates.io","package":"pyo3","purl":"pkg:cargo/pyo3","source":"ghsa"},{"ranges":[{"type":"semver","introduced":"0.0.0-0","status":"affected","fixed":"0.24.1"}],"ecosystem":"crates.io","package":"pyo3","purl":"pkg:cargo/pyo3","source":"rustsec"}],"references":[{"url":"https://github.com/PyO3/pyo3/issues/5005","tags":["report","web"],"sources":["ghsa","rustsec"]},{"url":"https://github.com/PyO3/pyo3/pull/5008","tags":["web"],"sources":["ghsa"]},{"url":"https://github.com/PyO3/pyo3","tags":["package"],"sources":["ghsa"]},{"url":"https://rustsec.org/advisories/RUSTSEC-2025-0020.html","tags":["advisory","web"],"sources":["ghsa","rustsec"]},{"url":"https://crates.io/crates/pyo3","tags":["package"],"sources":["rustsec"]}],"credits":[],"sources":[{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-pph8-gcv7-4qj5","url":"https://github.com/advisories/GHSA-pph8-gcv7-4qj5","licence":"CC-BY-4.0","modified":"2026-09-10T03:50:23.976Z"},{"source":"rustsec","name":"RustSec Advisory Database","id":"RUSTSEC-2025-0020","url":"https://rustsec.org/advisories/RUSTSEC-2025-0020.html","licence":"CC0-1.0","modified":"2025-10-28T06:29:25.695Z"}],"updatedAt":"2026-11-25T22:56:43.250Z"}