GHSA-f8x4-f32r-w556
Duplicate Advisory: PyO3 has a risk of use-after-free in `borrowed` reads from Python weak references
- Severity
- 0.0 / 10
- Medium · CVSS 4.0
- Exploit chance (EPSS)
- —
- No score published
- Known exploited
- No
- Not in CISA's catalog
- Weakness
- CWE-416 Use After Free
- Fix
0.22.4- Upgrade pyo3 to this version or later
Description
Duplicate Advisory
This advisory has been withdrawn because it is a duplicate of GHSA-6jgw-rgmm-7cv6. This link is maintained to preserve external references.
Original Advisory
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.
Affected versions
crates.io
| Package | Vulnerable | Fixed in |
|---|---|---|
| pyo3 | >= 0.22.0, < 0.22.4 |
0.22.4 |
How to fix
Move to the fixed version or later with your package manager, update the lockfile, and run your tests. If the package only arrives through another dependency, upgrade that dependency first. If none of its releases pulls a fixed version yet, force the version with your package manager's override.
pyo3 crates.io → 0.22.4
- cargo
cargo update -p pyo3 --precise 0.22.4
Severity breakdown
CVSS 4.0 0.0
CVSS:4.0/AV:L/AC:L/AT:N/PR:L/UI:N/VC:L/VI:L/VA:L/SC:N/SI:N/SA:N
- Attack vector
- Local
- Attack complexity
- Low
- Attack requirements
- None
- Privileges required
- Low
- User interaction
- None
- Confidentiality (vulnerable system)
- Low
- Integrity (vulnerable system)
- Low
- Availability (vulnerable system)
- Low
- Confidentiality (subsequent systems)
- None
- Integrity (subsequent systems)
- None
- Availability (subsequent systems)
- None
Weakness
CWE-416: Use After Free
The product reuses or references memory after it has been freed. At some point afterward, the memory may be allocated again and saved in another pointer, while the original pointer references a location somewhere within the new allocation. Any operations using the original pointer are no longer valid because the memory "belongs" to the code that operates on the new pointer.
How to prevent it
- Architecture and Design: Choose a language that provides automatic memory management.
- Implementation: When freeing pointers, be sure to set them to NULL once they are freed. However, the utilization of multiple or complex data structures may lower the usefulness of this strategy.
References
Packages
Other links
Timeline
- Published
- Last updated by the source
- Withdrawn
Related advisories
| Advisory | Severity | Why it's related |
|---|---|---|
| GHSA-chgr-c6px-7xpp PyO3 has a missing `Sync` bound on `PyCFunction::new_closure` closures | Medium | Also affects pyo3 |
| GHSA-36hh-v3qg-5jq4 PyO3 has an Out-of-bounds Read in `nth` / `nth_back` for `PyList` and `PyTuple` iterators | High | Also affects pyo3 |
| GHSA-47qc-857f-7w7f PyO3 has type confusion when accessing data from sublasses of subclasses of native types with `abi3` feature | High | Also affects pyo3 |
| GHSA-pph8-gcv7-4qj5 PyO3 Risk of buffer overflow in `PyString::from_object` | Low | Also affects pyo3 |
| GHSA-vxcf-c7mx-pg53 Build corruption when using `PYO3_CONFIG_FILE` environment variable | Medium | Also affects pyo3 |
| GHSA-6jgw-rgmm-7cv6 PyO3 has a risk of use-after-free in `borrowed` reads from Python weak references | Medium | Also affects pyo3 |
| GHSA-2vx6-fcw6-hpr6 Reference counting error in pyo3 | Medium | Also affects pyo3 |
| CVE-2026-109619 PHP has various global state that temporarily points into request memory. | Critical Known exploited | Same weakness, CWE-416 |
MergeHarbor checks every repository's dependencies against this database, ranks what matters by exploitability and reachability, routes it to the owning team and opens the fix pull request.
Check your repos with MergeHarbor