GHSA-v363-rrf2-5fmj Unsound use of str::from_utf8_unchecked on bytes which are not UTF-8

Not scored Published

An attacker can cause undefined behavior, potentially leading to crashes or code execution, by providing invalid UTF-8 bytes to the ferris-says library.

Exploited in the wild
Not known
Login needed
Not needed
Attackable
Not stated
Victim action needed
Not needed
Fix
Available

What is GHSA-v363-rrf2-5fmj?

GHSA-v363-rrf2-5fmj is a memory corruption vulnerability in ferris-says, published on 13 Jan 2024.

Official 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.

Which versions are affected by GHSA-v363-rrf2-5fmj?

5 open source packages ship an affected version, including ferris-says.

PackageAffectedFixed in
ferris-says crates.ioFrom 0.1.2 to 0.2.1None
ferris-says crates.ioFrom 0.1.2 to 0.2.1None
ferris-says crates.ioFrom 0.1.3-00.3.1
ferris-says crates.ioFrom 0.3.00.3.1
ferris-says crates.ioFrom 0.3.00.3.1

How do I fix GHSA-v363-rrf2-5fmj?

Upgrade ferris-says to 0.3.1 or later.

Upgrade to the fixed version. Memory-safe languages, compiler hardening and fuzzing prevent most new cases. More about Memory corruption.

Is GHSA-v363-rrf2-5fmj being exploited?

There is no known exploitation of GHSA-v363-rrf2-5fmj in the wild and no public exploit code.

Sources

Also known as RUSTSEC-2024-0001.

Is GHSA-v363-rrf2-5fmj in your software?

Upload an SBOM and sbomify checks it against every vulnerability here, every day.

Check your SBOMs for free