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

- Severity: not scored yet
- Known to be exploited: not in CISA's catalogue, which lists only what CISA has confirmed
- Published: 2026-07-21T12:00:00.000Z
- Modified: 2026-07-28T18:45:04.794Z

## 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.

(As written by RustSec Advisory Database.)

## Affected

- enum-map (crates.io): from 3.0.0-0.gat.0 before 3.1.0

## References

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

## Sources

- RustSec Advisory Database: [RUSTSEC-2026-0218](https://rustsec.org/advisories/RUSTSEC-2026-0218.html), CC0-1.0, modified 2026-07-28

---

Page: https://cve.day/RUSTSEC-2026-0218 · Whole record: https://cve.day/RUSTSEC-2026-0218.json · Rebuilt by cve.day 2026-11-25T22:56:43.386Z
