# RUSTSEC-2026-0218: Enum trait allows type confusion when manually implemented

- Database: RustSec
- Published: 2026-07-21
- Modified: 2026-07-28

## Affected versions

- enum-map (crates.io): from 3.0.0-0.gat.0, fixed in 3.1.0

## 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`:

```rust
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](https://codeberg.org/sugar700/enum-map/commit/7a8b8154323d426415a10accf104cd05c394cda9) by adding a `Value = V` bound to the `Array` type in the `Enum` trait.

## References

- https://crates.io/crates/enum-map
- https://rustsec.org/advisories/RUSTSEC-2026-0218.html
- https://codeberg.org/sugar700/enum-map/src/branch/master/CHANGELOG.md#version-310
- https://github.com/rustsec/advisory-db/issues/3060

Page: https://cve.now/RUSTSEC-2026-0218

Wrong or missing data? Send feedback: POST https://cve.now/api/v1/feedback (see https://cve.now/agents#feedback).
