Vulnerability HighRUSTSEC-2021-0048 · stackvector
RUSTSEC-2021-0048: StackVec::extend can write out of bounds when size_hint is incorrect
Short answerA security vulnerability in the stackvector crate: StackVec::extend can write out of bounds when size_hint is incorrect. High severity (CVSS 7.3). Fixed in 1.0.9: update to a fixed version.
| Crate | stackvector |
|---|---|
| Type | Vulnerability (memory-corruption) |
| Affected versions | Before 1.0.9. |
| Fixed in | 1.0.9 |
| Severity | High, CVSS 7.3 CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:L/A:L |
| Published | 2021-02-19 |
| Last changed | 2023-11-08 |
| Also known as | CVE-2021-29939, GHSA-9frf-r7c7-j2vg |
What to do
- See which version you have:
cargo tree -i stackvector(it also shows which of your dependencies pulls it in). - Update within your version requirement:
cargo update -p stackvector. If the fix is a newer major or minor than your requirement allows, raise it in Cargo.toml (for examplestackvector = "1.0.9") 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
StackVec::extend used the lower and upper bounds from an Iterator's size_hint to determine how many items to push into the stack based vector.
If the size_hint implementation returned a lower bound that was larger than the upper bound, StackVec would write out of bounds and overwrite memory on the stack. As mentioned by the size_hint documentation, size_hint is mainly for optimization and incorrect implementations should not lead to memory safety issues.
References
- Package: crates.io/crates/stackvector
- Advisory: rustsec.org/advisories/RUSTSEC-2021-0048.html
- Report: github.com/Alexhuszagh/rust-stackvector/issues/2
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 stackvector
Up next
Same cratestackvector: security historyEvery advisory for this crate, and whether it is safe to use today.Read it next →Did this answer your question?