Advisory

RUSTSEC-2026-0218

Also known as: None

Summary

Enum trait allows type confusion when manually implemented

Details

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.

Severity

Not rated by the source.

Dates

Published
2026-07-21 12:00 UTC
Modified
2026-07-28 18:45 UTC

Affected packages and fixes

enum-map

crates.io · All systems

Affected

  • introduced 3.0.0-0.gat.0, fixed 3.1.0 (semver)

Fixed versions

3.1.0

Fix

  • Fixed version 3.1.0
    cargo update -p enum-map --precise 3.1.0

Fix commands are the export's own generic commands. Ojuju never runs them. Check them against your setup first.

Check your own computer: guard packages check

View this record on OSV.dev

Source

Source: RustSec Advisory Database · CC0-1.0

Sources & licences