rkyv: Panic safety bugs in `InlineVec::clear` and `SerVec::clear` enable arbitrary code execution
Moderate severity
GitHub Reviewed
Published
May 15, 2026
to the GitHub Advisory Database
•
Updated May 15, 2026
Description
Published to the GitHub Advisory Database
May 15, 2026
Reviewed
May 15, 2026
Last updated
May 15, 2026
InlineVec::clear()andSerVec::clear()inrkyvwere not panic-safe. Both functions iterate over their elements and calldrop_in_placeon each, updatingself.lenonly after the loop. If an element'sDropimplementation panics during the loop,self.lenis 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.Technical Impact
Box<T>DropBoth vulnerabilities are triggerable entirely from safe Rust via
std::panic::catch_unwindand require no special privileges.References