CVE-2024-9979: PyO3 has a risk of use-after-free in `borrowed` reads from Python weak references
The family of functions to read "borrowed" values from Python weak references were fundamentally unsound, because the weak reference does itself not have ownership of the value. At any point the last strong reference could be cleared and the borrowed value would become dangling. In PyO3 0.22.4 these functions have all been deprecated and patched to leak a strong reference as a mitigation.
Published Oct 15, 2024
Affected packages
pyo3
- Ecosystem
- Rust (crates.io)
- Affected
- >= 0.22.0, < 0.22.4
- Fixed in
- 0.22.4
- Check
cargo tree -i pyo3
Advisory details
From the GitHub Advisory Database (CC BY 4.0).
The family of functions to read "borrowed" values from Python weak references were fundamentally unsound, because the weak reference does itself not have ownership of the value. At any point the last strong reference could be cleared and the borrowed value would become dangling.
In PyO3 0.22.4 these functions have all been deprecated and patched to leak a strong reference as a mitigation. PyO3 0.23 will remove these functions entirely.
References
- https://nvd.nist.gov/vuln/detail/CVE-2024-9979
- https://github.com/PyO3/pyo3/pull/4590
- https://access.redhat.com/security/cve/CVE-2024-9979
- https://bugzilla.redhat.com/show_bug.cgi?id=2318646
- https://crates.io/crates/pyo3
- https://rustsec.org/advisories/RUSTSEC-2024-0378.html
- https://github.com/advisories/GHSA-6jgw-rgmm-7cv6
How this page is made: the data panel comes from the GitHub Advisory Database, CISA’s KEV catalog, the NVD and FIRST EPSS, and updates twice a day. No analysis has been written for this entry yet. Methodology
More Rust (crates.io) vulnerabilities
All Rust (crates.io) entriesGHSA-36hh-v3qg-5jq4
PyO3 has an Out-of-bounds Read in `nth` / `nth_back` for `PyList` and `PyTuple` iterators
high8.7Jun 12, 2026GHSA-chgr-c6px-7xpp
PyO3 has a missing `Sync` bound on `PyCFunction::new_closure` closures
medium6.3Jun 12, 2026GHSA-47qc-857f-7w7f
PyO3 has type confusion when accessing data from sublasses of subclasses of native types with `abi3` feature
high7.2Feb 19, 2026GHSA-pph8-gcv7-4qj5
PyO3 Risk of buffer overflow in `PyString::from_object`
low2.9Apr 2, 2025GHSA-vxcf-c7mx-pg53
Build corruption when using `PYO3_CONFIG_FILE` environment variable
mediumDec 5, 2024
