{"answers":{"affected":"3 open source packages ship an affected version, including enum-map.","exploited":"There is no known exploitation of GHSA-rxhx-9fj6-6h2m in the wild and no public exploit code.","fix":"Upgrade enum-map to 2.0.2 or later.","what":"GHSA-rxhx-9fj6-6h2m is a memory corruption vulnerability in enum-map, published on 17 Feb 2022."},"fix_prompt":"Check this codebase for GHSA-rxhx-9fj6-6h2m and fix it if it is affected.\n\nWhat it is: GHSA-rxhx-9fj6-6h2m is a memory corruption vulnerability in enum-map, published on 17 Feb 2022. \nExploitation: There is no known exploitation of GHSA-rxhx-9fj6-6h2m in the wild and no public exploit code.\n\nAffected packages and fixed versions:\n- enum-map (crates.io): affected from 2.0.0-2; fixed in 2.0.2\n- enum-map (crates.io): affected from 2.0.0-2; fixed in 2.0.2\n- enum-map (crates.io): affected from 2.0.0-2; fixed in 2.0.2\n\nTask:\n1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.\n2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.\n3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.\n4. Run the tests and summarise what changed and why.\n5. If nothing in the project is affected, say so and change nothing.\n\nReference: https://insights.sbomify.com/GHSA-rxhx-9fj6-6h2m/ (Markdown: https://insights.sbomify.com/GHSA-rxhx-9fj6-6h2m/index.md)","id":"GHSA-rxhx-9fj6-6h2m","markdown":"https://insights.sbomify.com/GHSA-rxhx-9fj6-6h2m/index.md","name":"GHSA-rxhx-9fj6-6h2m","record":{"aliases":["RUSTSEC-2022-0010"],"analysis":{"component_type":"library","fix_type":"patch","impacts":["code_execution"],"network_reachable":"unknown","non_default_config":true,"product_category":"Rust enum-map library","requires_auth":"none","summary":"Incorrect manual implementation of the Enum trait in the enum-map crate can lead to uninitialized memory usage and arbitrary code execution.","user_interaction":"not_required","vuln_class":"memory_corruption"},"analysis_generated_by":"qwen3.8-flash-next","assigner":null,"cpe":[],"cvss":{"score":null,"severity":null,"source":null,"vector":null,"version":null},"cwes":[],"description":"Affected versions of this crate did not properly check the length of an enum when using `enum_map!` macro, trusting user-provided length.\n\nWhen the `LENGTH` in the `Enum` trait does not match the array length in the `EnumArray` trait, this can result in the initialization of the enum map with uninitialized types, which in turn can allow an attacker to execute arbitrary code.\n\nThis problem can only occur with a manual implementation of the Enum trait, it will never occur for enums that use `#[derive(Enum)]`.\n\nExample code that triggers this vulnerability looks like this:\n\n```rust\nenum E {\n    A,\n    B,\n    C,\n}\n\nimpl Enum for E {\n    const LENGTH: usize = 2;\n\n    fn from_usize(value: usize) -\u003e E {\n        match value {\n            0 =\u003e E::A,\n            1 =\u003e E::B,\n            2 =\u003e E::C,\n            _ =\u003e unimplemented!(),\n        }\n    }\n\n    fn into_usize(self) -\u003e usize {\n        self as usize\n    }\n}\n\nimpl\u003cV\u003e EnumArray\u003cV\u003e for E {\n    type Array = [V; 3];\n}\n\nlet _map: EnumMap\u003cE, String\u003e = enum_map! { _ =\u003e \"Hello, world!\".into() };\n```\n\nThe flaw was corrected in commit [b824e23](https://gitlab.com/KonradBorowski/enum-map/-/commit/b824e232f2fb47837740070096ac253df8e80dfc) by putting `LENGTH` property on sealed trait for macro to read.","ecosystems":["crates.io"],"exploits":{"exploitdb":null,"first_seen":null,"github_poc":null,"max_poc_stars":null,"metasploit":null,"nuclei":null,"refs":[],"tier":null},"has_fix":true,"headline":"enum_map macro can cause UB when `Enum` trait is incorrectly implemented","id":"GHSA-rxhx-9fj6-6h2m","indexable":true,"kev":null,"kind":"advisory","links":{"ecosystem":"crates.io","product":null,"products":[],"type":"memory_corruption","year":"2022"},"n_packages":3,"n_references":null,"packages":[{"ecosystem":"crates.io","fixed":["2.0.2"],"introduced":["2.0.0-2"],"last_affected":[],"package":"enum-map","purl":null,"source":"GHSA-rxhx-9fj6-6h2m"},{"ecosystem":"crates.io","fixed":["2.0.2"],"introduced":["2.0.0-2"],"last_affected":[],"package":"enum-map","purl":"pkg:cargo/enum-map","source":"GHSA-rxhx-9fj6-6h2m"},{"ecosystem":"crates.io","fixed":["2.0.2"],"introduced":["2.0.0-2"],"last_affected":[],"package":"enum-map","purl":"pkg:cargo/enum-map","source":"RUSTSEC-2022-0010"}],"products":null,"published":"2022-02-17","related":[],"sources":[{"class":"attribution","licence":"CC BY 4.0","name":"GitHub Advisory Database","prefix":"GHSA"},{"class":"open","licence":"CC0 1.0","name":"RustSec","prefix":"RUSTSEC"}],"ssvc":{"automatable":null,"exploitation":null,"technical_impact":null},"state":null,"updated":null,"vendors":null},"summary":"Incorrect manual implementation of the Enum trait in the enum-map crate can lead to uninitialized memory usage and arbitrary code execution.","url":"https://insights.sbomify.com/GHSA-rxhx-9fj6-6h2m/"}