GHSA-h6xm-c6r4-vmwf Unsound usages of `u8` type casting in spl-token-swap

Not scored Published

Unsound u8 casting in spl-token-swap allows misaligned pointer dereference or illegal type construction, potentially causing panics or undefined behavior.

Exploited in the wild
Not known
Login needed
Not needed
Attackable
Over the internet
Victim action needed
Not needed
Fix
None listed

What is GHSA-h6xm-c6r4-vmwf?

GHSA-h6xm-c6r4-vmwf is a memory corruption vulnerability in spl-token-swap, published on 19 Dec 2024. An attacker can exploit it over the internet without logging in, with no action from the victim.

Official description

The library provides a safe public API unpack to cast u8 array to arbitrary types, which can cause to undefined behaviors. The length check of array can only prevent out-of-bound access on the return type. However, it can't prevent misaligned pointer when casting u8 pointer to a type aligned to larger bytes. For example, if we assign u16 to T, misaligned raw pointer dereference could happen and cause to panic. Even if we pass the type aligned to same byte as u8 (e.g., bool), it could construct a illegal type since bool can only have 0 or 1 as bit patterns, which is also an undefined behavior. The further exploits of the bug here are still not clear, so we would report this issue as unsound.

The details of PoC to reproduce undefined behavior are provided in the issue.

Which versions are affected by GHSA-h6xm-c6r4-vmwf?

3 open source packages ship an affected version, including spl-token-swap.

PackageAffectedFixed in
spl-token-swap crates.ioAll versions to 3.0.0None
spl-token-swap crates.ioAll versions to 3.0.0None
spl-token-swap crates.ioFrom 0.0.0-0None

How do I fix GHSA-h6xm-c6r4-vmwf?

No fix has been published for GHSA-h6xm-c6r4-vmwf yet. Limit exposure of the affected software until one is available.

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

Is GHSA-h6xm-c6r4-vmwf being exploited?

There is no known exploitation of GHSA-h6xm-c6r4-vmwf in the wild and no public exploit code.

Sources

Also known as RUSTSEC-2024-0426.

Is GHSA-h6xm-c6r4-vmwf in your software?

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

Check your SBOMs for free