Skip to content

Commit b1350d8

Browse files
faerndjc
authored andcommitted
Add advisory on use-after-free in oneshot library
1 parent 2a69949 commit b1350d8

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
```toml
2+
[advisory]
3+
id = "RUSTSEC-0000-0000"
4+
package = "oneshot"
5+
date = "2026-01-25"
6+
url = "https://github.com/faern/oneshot/issues/73"
7+
informational = "unsound"
8+
keywords = ["memory-safety", "use-after-free"]
9+
10+
[affected]
11+
#arch = ["x86"]
12+
#os = ["windows"]
13+
14+
[versions]
15+
patched = [">= 0.1.12"]
16+
unaffected = ["<= 0.1.1"]
17+
```
18+
19+
# Potential use-after-free in `oneshot` when used asynchronously
20+
21+
There is a race condition that can lead to a use-after-free if a `oneshot::Receiver` is polled but then dropped instead of polled to completion. This could happen if the receiver future was cancelled while receiving, for example by being wrapped in a timeout future or similar.
22+
23+
When the `Receiver` is polled (`Future::poll`) it writes a waker to the channel and sets it to the `RECEIVING` state. If the `Receiver` was then dropped (instead of polled to completion), the `Drop` implementation on `Receiver` unconditionally swapped the channel state to `DISCONNECTED` and only after doing so it read back its waker from the heap allocation and dropped it. The problem is that the `DISCONNECTED` state could be observed by the `Sender`, which would lead to it deallocating the channel heap memory. If the `Sender` manage to free the channel before the `Receiver` managed to proceed to dropping the waker, then the `Receiver` would read from the freed channel memory (use-after-free).
24+
25+
The fix was submitted in https://github.com/faern/oneshot/pull/74 and published as part of `oneshot` version `0.1.12`.

0 commit comments

Comments
 (0)