# GHSA-mr2v-63pc-gmr4: Panic-safety unsoundness in `BitVecCore::clear` (double-free / use-after-free)

- Severity: not scored yet
- Known to be exploited: not in CISA's catalogue, which lists only what CISA has confirmed
- Published: 2026-08-24T12:00:00.000Z
- Modified: 2026-08-25T02:45:03.396Z
- Also known as: RUSTSEC-2026-0267

## Description

`BitVecCore::clear` drops every occupied element with `drop_in_place` and only
afterwards clears the occupancy bits and resets `len`. If an element's `Drop`
panics, those metadata updates are skipped, so the slot of the already-dropped
element stays marked as occupied. `BitVecCore::drop` calls `clear()` again,
visits the same slot, and drops the element a second time — a double-free /
use-after-free reachable from safe Rust.

Reachable via the public `StableVec::clear` and `ExternStableVec::clear`, which
delegate to `BitVecCore::clear`.

## Impact

* CWE-415 (Double Free): the same allocation is freed twice.
* CWE-416 (Use-After-Free): a freed allocation is accessed during a repeated `Drop`.

Reachable entirely from safe Rust via `catch_unwind` with element types whose
`Drop` can panic. Confirmed under AddressSanitizer on 0.4.2.

## Fix

Fixed in `stable-vec` 0.4.3 by removing each element via `remove_at`, which
clears the occupancy bit before taking the value out.

Release 0.4.3 also fixes several other panic-safety issues found by the
maintainer; see [GHSA-mr2v-63pc-gmr4](https://github.com/LukasKalbertodt/stable-vec/security/advisories/GHSA-mr2v-63pc-gmr4)
and the 0.4.3 changelog for the full list.

(As written by RustSec Advisory Database.)

## Affected

- stable-vec (crates.io): from 0.0.0-0 before 0.4.3

## References

- <https://crates.io/crates/stable-vec> (package)
- <https://rustsec.org/advisories/RUSTSEC-2026-0267.html> (advisory)
- <https://github.com/LukasKalbertodt/stable-vec/pull/51> (web)

## Sources

- RustSec Advisory Database: [RUSTSEC-2026-0267](https://rustsec.org/advisories/RUSTSEC-2026-0267.html), CC0-1.0, modified 2026-08-25

---

Page: https://cve.day/GHSA-mr2v-63pc-gmr4 · Whole record: https://cve.day/GHSA-mr2v-63pc-gmr4.json · Rebuilt by cve.day 2026-11-25T22:56:43.401Z
