Unsound MediumRUSTSEC-2026-0122 · rkyv
RUSTSEC-2026-0122: Potential use-after-free due to lack of panic safety in `InlineVec::clear` and `SerVec::clear`
Short answerrkyv has an API that can cause undefined behaviour from safe code: Potential use-after-free due to lack of panic safety in `InlineVec::clear` and `SerVec::clear`. Fixed in 0.8.16.
| Crate | rkyv |
|---|---|
| Type | Unsound (code-execution, memory-corruption) |
| Affected versions | From 0.8.0 before 0.8.16. |
| Fixed in | 0.8.16 |
| Severity | Medium (GitHub rating) |
| Published | 2026-04-23 |
| Last changed | 2026-05-16 |
| Also known as | GHSA-vfvv-c25p-m7mm |
What to do
- See which version you have:
cargo tree -i rkyv(it also shows which of your dependencies pulls it in). - Update within your version requirement:
cargo update -p rkyv. If the fix is a newer major or minor than your requirement allows, raise it in Cargo.toml (for examplerkyv = "0.8.16") 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
InlineVec::clear() and SerVec::clear() in rkyv were not panic-safe. Both functions iterate over their elements and call drop_in_place on each, updating self.len only *after* the loop. If an element's Drop implementation panics during the loop, self.len is left at its original value.
A subsequent invocation of clear() on the same container then re-visits the already-freed elements:
InlineVec::clear()is called again fromInlineVec's ownDropimplementation when the value is later dropped.SerVec::clear()is called again bySerVec::with_capacity()after the user closure returns.
Impact
- **CWE-415 (Double Free):** heap corruption when the element type is one that owns memory, such as
Box<T>orVec<T> - **CWE-416 (Use-After-Free):** memory corruption when an element is accessed following a caught panic
Both types of undefined behavior can be invoked in safe Rust, but only if unwinding panics are enabled and std::panic::catch_unwind is used.
References
- Package: crates.io/crates/rkyv
- Advisory: rustsec.org/advisories/RUSTSEC-2026-0122.html
- Web: github.com/rkyv/rkyv/commit/5828cf5c27b664eb4432c4a93d4769e12e5e42fb
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 rkyv
- Vulnerability HighRUSTSEC-2021-0054 · 2021-04-28Archives may contain uninitialized memory
- VulnerabilityRUSTSEC-2026-0001 · 2026-01-05Potential Undefined Behaviors in `Arc<T>`/`Rc<T>` impls of `from_value` on OOM
- VulnerabilityRUSTSEC-2026-0233 · 2026-05-11Crafted archives can cause a use-after-free during deserialization
- VulnerabilityRUSTSEC-2026-0234 · 2026-05-11Insufficient archive validation can cause out-of-bounds reads in archives containing hash tables
- VulnerabilityRUSTSEC-2026-0235 · 2026-05-13Insufficient archive validation can cause out-of-bounds reads in archives containing Rc/Arc
Up next
Same craterkyv: security historyEvery advisory for this crate, and whether it is safe to use today.Read it next →Did this answer your question?