Unsound MediumRUSTSEC-2024-0404 · anstream
RUSTSEC-2024-0404: Unsoundness in anstream
Short answeranstream has an API that can cause undefined behaviour from safe code: Unsoundness in anstream. Fixed in 0.6.8.
| Crate | anstream |
|---|---|
| Type | Unsound |
| Affected versions | Before 0.6.8. |
| Fixed in | 0.6.8 |
| Severity | Medium (GitHub rating) |
| Published | 2024-09-08 |
| Last changed | 2026-07-17 |
| Also known as | GHSA-2rxc-gjrp-vjhx |
| Affected functions | anstream::adapter::strip_str |
What to do
- See which version you have:
cargo tree -i anstream(it also shows which of your dependencies pulls it in). - Update within your version requirement:
cargo update -p anstream. If the fix is a newer major or minor than your requirement allows, raise it in Cargo.toml (for exampleanstream = "0.6.8") or update the dependency that pulls it in. - Check again with
cargo audit, or paste your Cargo.lock into our Cargo.toml checker.
Details from the advisory
When given a valid UTF8 string "ö\x1b😀", the function in crates/anstream/src/adapter/strip.rs will be confused. The UTF8 bytes are \xc3\xb6 then \x1b then \xf0\x9f\x98\x80.
When looping over "non-printable bytes" \x1b\xf0 will be considered as some non-printable sequence.
This will produce a broken str from the incorrectly segmented bytes via str::from_utf8_unchecked, and that should never happen.
Full credit goes to @Ralith who reviewed this code and asked @burakemir to follow up.
References
- Package: crates.io/crates/anstream
- Advisory: rustsec.org/advisories/RUSTSEC-2024-0404.html
- Report: github.com/rust-cli/anstyle/issues/156
From the RustSec Advisory Database (CC0-1.0) via the OSV export, downloaded Oct 24, 2026. Severity score computed from the published CVSS vector.
Up next
Same crateanstream: security historyEvery advisory for this crate, and whether it is safe to use today.Read it next →Did this answer your question?