Skip to content

Commit b71a917

Browse files
authored
risk of use-after-free in PyO3 borrowing from weak refrences (#2101)
* risk of use-after-free in PyO3 borrowing from weak refrences * correct trait name
1 parent acb7ce4 commit b71a917

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

crates/pyo3/RUSTSEC-0000-0000.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
```toml
2+
[advisory]
3+
id = "RUSTSEC-0000-0000"
4+
package = "pyo3"
5+
date = "2024-10-12"
6+
url = "https://github.com/PyO3/pyo3/pull/4590"
7+
categories = ["memory-corruption"]
8+
keywords = ["use-after-free"]
9+
10+
[affected]
11+
functions = { "pyo3::types::PyWeakrefMethods::upgrade_borrowed_as" = ["< 0.22.4, >= 0.22.0"], "pyo3::types::PyWeakrefMethods::upgrade_borrowed_as_unchecked" = ["< 0.22.4, >= 0.22.0"], "pyo3::types::PyWeakrefMethods::upgrade_borrowed_as_exact" = ["< 0.22.4, >= 0.22.0"], "pyo3::types::PyWeakrefMethods::upgrade_borrowed" = ["< 0.22.4, >= 0.22.0"], "pyo3::types::PyWeakrefMethods::get_object_borrowed" = ["< 0.22.4, >= 0.22.0"] }
12+
13+
[versions]
14+
patched = [">= 0.22.4"]
15+
unaffected = ["< 0.22.0"]
16+
```
17+
18+
# Risk of use-after-free in `borrowed` reads from Python weak references
19+
20+
The family of functions to read "borrowed" values from Python weak references
21+
were fundamentally unsound, because the weak reference does itself not have
22+
ownership of the value. At any point the last strong reference could
23+
be cleared and the borrowed value would become dangling.
24+
25+
In PyO3 0.22.4 these functions have all been deprecated and patched to leak a
26+
strong reference as a mitigation. PyO3 0.23 will remove these functions entirely.
27+

0 commit comments

Comments
 (0)