Skip to content

Commit 7b8823b

Browse files
authored
Unsound use of str::from_utf8_unchecked in ferris-says (#1848)
1 parent a5fb72d commit 7b8823b

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
```toml
2+
[advisory]
3+
id = "RUSTSEC-0000-0000"
4+
package = "ferris-says"
5+
date = "2024-01-13"
6+
url = "https://github.com/rust-lang/ferris-says/pull/21"
7+
informational = "unsound"
8+
9+
[versions]
10+
patched = [">= 0.3.1"]
11+
unaffected = ["<= 0.1.2"]
12+
```
13+
14+
# Unsound use of str::from_utf8_unchecked on bytes which are not UTF-8
15+
16+
Affected versions receive a `&[u8]` from the caller through a safe API, and pass
17+
it directly to the unsafe `str::from_utf8_unchecked` function.
18+
19+
The behavior of `ferris_says::say` is undefined if the bytes from the caller
20+
don't happen to be valid UTF-8.
21+
22+
The flaw was corrected in [ferris-says#21] by using the safe `str::from_utf8`
23+
instead, and returning an error on invalid input. However this fix has not yet
24+
been published to crates.io as a patch version for 0.2.
25+
26+
Separately, [ferris-says#32] has introduced a different API for version 0.3
27+
which accepts input as `&str` rather than `&[u8]`, so is unaffected by this bug.
28+
29+
[ferris-says#21]: https://github.com/rust-lang/ferris-says/pull/21
30+
[ferris-says#32]: https://github.com/rust-lang/ferris-says/pull/32

0 commit comments

Comments
 (0)