Vulnerability MediumRUSTSEC-2025-0050 · id-map
RUSTSEC-2025-0050: IdMap::from_iter may lead to uninitialized memory being freed on drop
Short answerA security vulnerability in the id-map crate: IdMap::from_iter may lead to uninitialized memory being freed on drop. GitHub rates it Medium. Fixed in 0.2.2: update to a fixed version.
| Crate | id-map |
|---|---|
| Type | Vulnerability (memory-corruption) |
| Affected versions | From 0.1.6 before 0.2.2. |
| Fixed in | 0.2.2 |
| Severity | Medium (GitHub rating) |
| Published | 2025-08-14 |
| Last changed | 2025-10-28 |
| Also known as | GHSA-qq4c-hm99-979m |
| Affected functions | id_map::IdMap::from_iter |
What to do
- See which version you have:
cargo tree -i id-map(it also shows which of your dependencies pulls it in). - Update within your version requirement:
cargo update -p id-map. If the fix is a newer major or minor than your requirement allows, raise it in Cargo.toml (for exampleid-map = "0.2.2") or update the dependency that pulls it in. - Check again with
cargo audit, or paste your Cargo.lock into our Cargo.toml checker.
Details from the advisory
Due to a flaw in the constructor id_map::IdMap::from_iter, ill-formed objects may be created in which the amount of actually initialized memory is less than what is expected by the fields of IdMap. Specifically, the field ids is initialized based on the capacity of the vector values, which is constructed from the provided iterator. However, the length of this vector may be smaller than its capacity.
In such cases, when the resulting IdMap is dropped, its destructor incorrectly assumes that values contains ids.len() == values.capacity() initialized elements and attempts to iterate over and drop them. This leads to dereferencing and attempting to free uninitialized memory, resulting in undefined behavior and potential segmentation faults.
The bug was fixed in commit fab6922, and all unsafe code was removed from the crate.
Note that the maintainer recommends using the following alternatives:
References
- Package: crates.io/crates/id-map
- Advisory: rustsec.org/advisories/RUSTSEC-2025-0050.html
- Report: github.com/andrewhickman/id-map/issues/4
From the RustSec Advisory Database (CC0-1.0) via the OSV export, downloaded Oct 24, 2026. Severity score computed from the published CVSS vector.
Other advisories for id-map
Up next
Same crateid-map: security historyEvery advisory for this crate, and whether it is safe to use today.Read it next →Did this answer your question?