GHSA-74r5-g7vc-j2v2 zerovec-derive incorrectly uses `#[repr(packed)]`
Attackers can trigger illegal memory accesses and potential code execution in applications using the zerovec-derive crate due to incorrect struct layout assumptions.
- Exploited in the wild
- Not known
- Login needed
- Not needed
- Attackable
- Not stated
- Victim action needed
- Not needed
- Fix
- Available
What is GHSA-74r5-g7vc-j2v2?
GHSA-74r5-g7vc-j2v2 is a memory corruption vulnerability in zerovec-derive, published on 1 Jul 2024.
Official description
The affected versions make unsafe memory accesses under the assumption that #[repr(packed)] has a guaranteed field order.
The Rust specification does not guarantee this, and https://github.com/rust-lang/rust/pull/125360 (1.80.0-beta) starts
reordering fields of #[repr(packed)] structs, leading to illegal memory accesses.
The patched versions 0.9.7 and 0.10.3 use #[repr(C, packed)], which guarantees field order.
Which versions are affected by GHSA-74r5-g7vc-j2v2?
5 open source packages ship an affected version, including zerovec-derive.
| Package | Affected | Fixed in |
|---|---|---|
zerovec-derive crates.io | All versions | 0.9.7 |
zerovec-derive crates.io | All versions | 0.9.7 |
zerovec-derive crates.io | From 0.0.0-0 | 0.9.7, 0.10.3 |
zerovec-derive crates.io | From 0.10.0 | 0.10.3 |
zerovec-derive crates.io | From 0.10.0 | 0.10.3 |
How do I fix GHSA-74r5-g7vc-j2v2?
Upgrade zerovec-derive to a fixed version for your release line: 0.9.7 or 0.10.3.
Upgrade to the fixed version. Memory-safe languages, compiler hardening and fuzzing prevent most new cases. More about Memory corruption.
Is GHSA-74r5-g7vc-j2v2 being exploited?
There is no known exploitation of GHSA-74r5-g7vc-j2v2 in the wild and no public exploit code.
Sources
Also known as RUSTSEC-2024-0346.