Rust advisories / spl-token-swap
Unsound MediumRUSTSEC-2024-0426 · spl-token-swap
RUSTSEC-2024-0426: Unsound usages of `u8` type casting
Short answerspl-token-swap has an API that can cause undefined behaviour from safe code: Unsound usages of `u8` type casting. No fixed version yet.
| Crate | spl-token-swap |
|---|---|
| Type | Unsound |
| Affected versions | Every version. |
| Fixed in | none |
| Severity | Medium (GitHub rating) |
| Published | 2024-12-19 |
| Last changed | 2025-10-28 |
| Also known as | GHSA-h6xm-c6r4-vmwf |
| Affected functions | spl_token_swap::instruction::unpack |
What to do
- Find who pulls it in:
cargo tree -i spl-token-swap. - Avoid the affected API (
spl_token_swap::instruction::unpack), or replace the crate.
Details from the advisory
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.
References
- Package: crates.io/crates/spl-token-swap
- Advisory: rustsec.org/advisories/RUSTSEC-2024-0426.html
- Report: github.com/solana-labs/solana-program-library/issues/5243
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
Are you affected?Check your whole dependency treePaste Cargo.lock: every advisory, for your exact versions.Read it next →Also worth your time
Did this answer your question?