GHSA-7v4j-8wvr-v55r `array!` macro is unsound when its length is impure constant
Unsound array initialization via impure constants allows arbitrary code execution in Rust applications using the affected macro.
- Exploited in the wild
- Not known
- Login needed
- Not needed
- Attackable
- Not stated
- Victim action needed
- Not needed
- Fix
- Available
What is GHSA-7v4j-8wvr-v55r?
GHSA-7v4j-8wvr-v55r is a memory corruption vulnerability in array-macro, published on 27 Apr 2022.
Official description
Affected versions of this crate did substitute the array length provided by an user at compile-time multiple times.
When an impure constant expression is passed as an array length (such as a result of an impure procedural macro), this can result in the initialization of an array with uninitialized types, which in turn can allow an attacker to execute arbitrary code.
The flaw was corrected in commit d5b63f72 by making sure that array length is substituted just once.
Which versions are affected by GHSA-7v4j-8wvr-v55r?
3 open source packages ship an affected version, including array-macro.
| Package | Affected | Fixed in |
|---|---|---|
array-macro crates.io | From 2.1.0 | 2.1.2 |
array-macro crates.io | From 2.1.0 | 2.1.2 |
array-macro crates.io | From 2.1.0 | 2.1.2 |
How do I fix GHSA-7v4j-8wvr-v55r?
Upgrade array-macro to 2.1.2 or later.
Upgrade to the fixed version. Memory-safe languages, compiler hardening and fuzzing prevent most new cases. More about Memory corruption.
Is GHSA-7v4j-8wvr-v55r being exploited?
There is no known exploitation of GHSA-7v4j-8wvr-v55r in the wild and no public exploit code.
Sources
Also known as RUSTSEC-2022-0017.