{"id":"RUSTSEC-2026-0218","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`.\n\nThis can result in type confusion, and consequently memory corruption, when a manual `Enum` implementation declares an `Array\u003cV\u003e` whose elements are not actually of type `V`:\n\n```rust\nstruct IntentionallyWrong;\n\nimpl Enum for IntentionallyWrong {\n    type Array\u003cV\u003e = [String; 4];\n\n    fn from_usize(_: usize) -\u003e Self {\n        IntentionallyWrong\n    }\n\n    fn into_usize(self) -\u003e usize {\n        0\n    }\n}\n\nenum_map! { IntentionallyWrong =\u003e 42 };\n```\n\nThe 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.","modified":"2026-07-28T18:45:04.794215742Z","published":"2026-07-21T12:00:00Z","database_specific":{"license":"CC0-1.0"},"references":[{"type":"PACKAGE","url":"https://crates.io/crates/enum-map"},{"type":"ADVISORY","url":"https://rustsec.org/advisories/RUSTSEC-2026-0218.html"},{"type":"WEB","url":"https://codeberg.org/sugar700/enum-map/src/branch/master/CHANGELOG.md#version-310"},{"type":"REPORT","url":"https://github.com/rustsec/advisory-db/issues/3060"}],"affected":[{"package":{"name":"enum-map","ecosystem":"crates.io","purl":"pkg:cargo/enum-map"},"ranges":[{"type":"SEMVER","events":[{"introduced":"3.0.0-0.gat.0"},{"fixed":"3.1.0"}]}],"ecosystem_specific":{"affected_functions":null,"affects":{"arch":[],"os":[],"functions":[]}},"database_specific":{"informational":"unsound","categories":["memory-corruption"],"source":"https://github.com/rustsec/advisory-db/blob/osv/crates/RUSTSEC-2026-0218.json","cvss":null}}],"schema_version":"1.7.5"}