{"id":"RUSTSEC-2026-0301","revision":"920bfe57f82849b6bc77b14fcf65ff96","records":[{"revision":"920bfe57f82849b6bc77b14fcf65ff96","observedAt":"2026-10-24T13:19:54.901+00:00","statement":{"source":"osv","id":"RUSTSEC-2026-0301","aliases":[],"title":"Double free in `StackVec::retain` when a predicate or element `Drop` panics","description":"## Summary\n\n`StackVec::retain` committed its new length to `self.len` only after\nits internal loop completed. If the retain predicate or a removed\nelement's `Drop` implementation panicked before the loop finished,\nunwinding proceeded with `self.len` still equal to the original,\npre-retain length, leaving either a duplicated or already-destroyed\nelement inside `0..len`. `StackVec`'s own `Drop` then revisited that\nslot, causing a double-drop (and for heap-owning types, a double-free).\n\n## Impact\n\nAffects `StackVec<T, CAP>::retain` for `T: Drop` types where the\npredicate or the removed element's destructor can panic, on builds\nwith unwinding enabled (`panic = \"unwind\"`). `no_std`/`panic = \"abort\"`\nbuilds cannot trigger this, since unwinding never occurs.\n\n## Patch\n\nFixed in 0.3.3 using an unwind-safe backshift guard, matching the\napproach `alloc::vec::Vec::retain` uses.","state":0,"publishedAt":"2026-09-22T12:00:00+00:00","modifiedAt":"2026-09-22T21:00:02.8709179+00:00","affected":[{"ecosystem":"crates.io","name":"stack_collections","ranges":[{"type":"SEMVER","events":[{"kind":"introduced","version":"0.3.0"},{"kind":"fixed","version":"0.3.3"}]}],"versions":[],"rawVersionEvidence":null}],"metrics":[],"references":["https://crates.io/crates/stack_collections","https://rustsec.org/advisories/RUSTSEC-2026-0301.html","https://github.com/OverwrittenCode/stack_collections/pull/4"],"sourceUrl":"https://osv.dev/vulnerability/RUSTSEC-2026-0301","license":"OSV · upstream source license applies","key":"osv:RUSTSEC-2026-0301","identifiers":["RUSTSEC-2026-0301"]},"retained":false,"historicalAffected":[]}],"coverage":[]}