RustSec logo

HistoryEditJSON (OSV)

RUSTSEC-2026-0122

Potential use-after-free due to lack of panic safety in InlineVec::clear and SerVec::clear

Reported
Issued
Package
rkyv (crates.io)
Type
INFO Unsound
Categories
Keywords
#panic-safety #memory-safety #use-after-free #double-free
References
Patched
  • >=0.8.16
Unaffected
  • <0.8.0

Description

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:

Impact

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.

Advisory available under CC0-1.0 license.