# RUSTSEC-2024-0404: Unsoundness in anstream

- Database: RustSec
- Published: 2024-09-08
- Modified: 2026-07-17

## Also published as

- [GHSA-2RXC-GJRP-VJHX](https://cve.now/GHSA-2RXC-GJRP-VJHX.md) (GitHub)

## Affected versions

- anstream (crates.io): fixed in 0.6.8

## Description

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](https://github.com/Ralith) who reviewed this code and
asked [@burakemir](https://github.com/burakemir) to follow up.

## References

- https://crates.io/crates/anstream
- https://rustsec.org/advisories/RUSTSEC-2024-0404.html
- https://github.com/rust-cli/anstyle/issues/156

Page: https://cve.now/RUSTSEC-2024-0404

Wrong or missing data? Send feedback: POST https://cve.now/api/v1/feedback (see https://cve.now/agents#feedback).
