# RUSTSEC-2024-0001: Unsound use of str::from\_utf8\_unchecked on bytes which are not UTF-8

- Database: RustSec
- Published: 2024-01-13
- Modified: 2024-02-10

## Also published as

- [GHSA-V363-RRF2-5FMJ](https://cve.now/GHSA-V363-RRF2-5FMJ.md) (GitHub)

## Affected versions

- ferris-says (crates.io): from 0.1.3-0, fixed in 0.3.1

## Description

Affected versions receive a `&[u8]` from the caller through a safe API, and pass
it directly to the unsafe `str::from_utf8_unchecked` function.

The behavior of `ferris_says::say` is undefined if the bytes from the caller
don't happen to be valid UTF-8.

The flaw was corrected in [ferris-says#21] by using the safe `str::from_utf8`
instead, and returning an error on invalid input. However this fix has not yet
been published to crates.io as a patch version for 0.2.

Separately, [ferris-says#32] has introduced a different API for version 0.3
which accepts input as `&str` rather than `&[u8]`, so is unaffected by this bug.

[ferris-says#21]: https://github.com/rust-lang/ferris-says/pull/21
[ferris-says#32]: https://github.com/rust-lang/ferris-says/pull/32

## References

- https://crates.io/crates/ferris-says
- https://rustsec.org/advisories/RUSTSEC-2024-0001.html
- https://github.com/rust-lang/ferris-says/pull/21

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

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