{"id":"RUSTSEC-2026-0218","aliases":["RUSTSEC-2026-0218"],"related":[],"kind":"vulnerability","state":"published","title":"`Enum` trait allows type confusion when manually implemented","summary":"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<V>` whose elements are not actually of type `V`:\n\n```rust\nstruct IntentionallyWrong;\n\nimpl Enum for IntentionallyWrong {\n    type Array<V> = [String; 4];\n\n    fn from_usize(_: usize) -> Self {\n        IntentionallyWrong\n    }\n\n    fn into_usize(self) -> usize {\n        0\n    }\n}\n\nenum_map! { IntentionallyWrong => 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.","summaryFormat":"markdown","summarySource":"rustsec","descriptions":[{"lang":"en","text":"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<V>` whose elements are not actually of type `V`:\n\n```rust\nstruct IntentionallyWrong;\n\nimpl Enum for IntentionallyWrong {\n    type Array<V> = [String; 4];\n\n    fn from_usize(_: usize) -> Self {\n        IntentionallyWrong\n    }\n\n    fn into_usize(self) -> usize {\n        0\n    }\n}\n\nenum_map! { IntentionallyWrong => 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.","format":"markdown","source":"rustsec"}],"published":"2026-07-21T12:00:00.000Z","modified":"2026-07-28T18:45:04.794Z","severities":[],"cwes":[],"affected":[{"ranges":[{"type":"semver","introduced":"3.0.0-0.gat.0","status":"affected","fixed":"3.1.0"}],"ecosystem":"crates.io","package":"enum-map","purl":"pkg:cargo/enum-map","source":"rustsec"}],"references":[{"url":"https://crates.io/crates/enum-map","tags":["package"],"sources":["rustsec"]},{"url":"https://rustsec.org/advisories/RUSTSEC-2026-0218.html","tags":["advisory"],"sources":["rustsec"]},{"url":"https://codeberg.org/sugar700/enum-map/src/branch/master/CHANGELOG.md#version-310","tags":["web"],"sources":["rustsec"]},{"url":"https://github.com/rustsec/advisory-db/issues/3060","tags":["report"],"sources":["rustsec"]}],"credits":[],"sources":[{"source":"rustsec","name":"RustSec Advisory Database","id":"RUSTSEC-2026-0218","url":"https://rustsec.org/advisories/RUSTSEC-2026-0218.html","licence":"CC0-1.0","modified":"2026-07-28T18:45:04.794Z"}],"updatedAt":"2026-11-25T22:56:43.386Z"}