RUSTSEC-2026-0218 `Enum` trait allows type confusion when manually implemented
A type confusion vulnerability in the enum-map crate allows memory corruption when the Enum trait is manually implemented incorrectly.
- Exploited in the wild
- Not known
- Login needed
- Not needed
- Attackable
- Not stated
- Victim action needed
- Not needed
- Fix
- Available
What is RUSTSEC-2026-0218?
RUSTSEC-2026-0218 is a memory corruption vulnerability in enum-map, published on 21 Jul 2026.
Official description
Affected versions of this crate did not require the element type of the Array associated type in the Enum trait to match the array's generic parameter V.
This can result in type confusion, and consequently memory corruption, when a manual Enum implementation declares an Array<V> whose elements are not actually of type V:
struct IntentionallyWrong;
impl Enum for IntentionallyWrong {
type Array<V> = [String; 4];
fn from_usize(_: usize) -> Self {
IntentionallyWrong
}
fn into_usize(self) -> usize {
0
}
}
enum_map! { IntentionallyWrong => 42 };
The flaw was corrected in commit 7a8b815432 by adding a Value = V bound to the Array type in the Enum trait.
Which versions are affected by RUSTSEC-2026-0218?
1 open source package ship an affected version, including enum-map.
| Package | Affected | Fixed in |
|---|---|---|
enum-map crates.io | From 3.0.0-0.gat.0 | 3.1.0 |
How do I fix RUSTSEC-2026-0218?
Upgrade enum-map to 3.1.0 or later.
Upgrade to the fixed version. Memory-safe languages, compiler hardening and fuzzing prevent most new cases. More about Memory corruption.
Is RUSTSEC-2026-0218 being exploited?
There is no known exploitation of RUSTSEC-2026-0218 in the wild and no public exploit code.