# rkyv memory corruption via panic-safety bugs in clear functions

Source: https://junglewise.ai/threats/rkyv-memory-corruption-via-panic-safety-bugs-in-clear-functions-5d313d34  
Publisher: Junglewise Threat Intelligence, https://junglewise.ai/threats  
Published: 2026-05-15. Updated: 2026-05-15  
License: CC BY 4.0 with a link back

Severity: medium · CVSS 6.9 · Published 2026-05-15

rkyv is a high-performance data serialization library for the Rust programming language. A flaw in how the library handles memory cleanup during errors could allow an attacker to cause a program crash or potentially execute unauthorized code. This occurs when the library attempts to clear data from memory but fails to properly track which items have already been deleted, leading to memory corruption.

Technologies: [rkyv (crates.io)](https://junglewise.ai/threats/technologies/rkyv). Vendors: [crates.io](https://junglewise.ai/threats/vendors/crates-io).

## Quick answers

**Is This vulnerability exploited in the wild?** No. Junglewise Threat Intelligence has no report of This vulnerability being exploited in the wild.

**How severe is This vulnerability?** Medium severity, with a CVSS score of 6.9, published 15 May 2026.

**Which products and versions are affected?** rkyv (crates.io) >= 0.8.0, < 0.8.16.

**Is there a fix for This vulnerability?** A patch was published on 2026-05-15: Version 0.8.16 released and GHSA published Junglewise finds every place you run it, drafts the upgrade and applies it once you approve.

**How is This vulnerability attacked?** It is attacked over the network, in a software library.

**Am I affected?** Check whether you run rkyv (crates.io) at an affected version. Junglewise does that check for you around the clock: connect your code, cloud and domains, and it matches new vulnerabilities like this one against what you actually run and tells you when one reaches you.

## Technical details

The `InlineVec::clear` and `SerVec::clear` functions in rkyv are not panic-safe. These functions iterate through elements and call `drop_in_place` on each, but only update the internal length counter after the loop completes. If an element's `Drop` implementation panics, the length remains at its original value. This leads to a double-free or use-after-free scenario when the container is dropped or cleared again, as the already-dropped elements are processed a second time. The vulnerability is triggerable from safe Rust using `std::panic::catch_unwind` and was fixed in version 0.8.16 by updating the length before dropping elements.

## Affected products

- rkyv rkyv >= 0.8.0, < 0.8.16

## Timeline

- 2026-04-23: other: Reported
- 2026-05-11: advisory: RustSec advisory issued
- 2026-05-15: patched: Version 0.8.16 released and GHSA published

## References

- [https://github.com/rkyv/rkyv/commit/5828cf5c27b664eb4432c4a93d4769e12e5e42fb](https://github.com/rkyv/rkyv/commit/5828cf5c27b664eb4432c4a93d4769e12e5e42fb)
- [https://rustsec.org/advisories/RUSTSEC-2026-0122.html](https://rustsec.org/advisories/RUSTSEC-2026-0122.html)

## Related threats

- [RUSTSEC-2026-0235 - Insufficient archive validation can cause out-of-bounds reads in archives containing Rc/Arc](https://junglewise.ai/threats/rustsec-2026-0235-insufficient-archive-validation-can-cause-out-of-ced94533)
- [RUSTSEC-2026-0233 - Crafted archives can cause a use-after-free during deserialization](https://junglewise.ai/threats/rustsec-2026-0233-crafted-archives-can-cause-a-use-after-free-during-0be0b750)
- [RUSTSEC-2026-0234 - Insufficient archive validation can cause out-of-bounds reads in archives containing hash tables](https://junglewise.ai/threats/rustsec-2026-0234-insufficient-archive-validation-can-cause-out-of-d8f5fa22)
- [RUSTSEC-2026-0122 - Potential use-after-free due to lack of panic safety in `InlineVec::clear` and `SerVec::clear`](https://junglewise.ai/threats/rustsec-2026-0122-potential-use-after-free-due-to-lack-of-panic-safety-f2a16c90)
- [RUSTSEC-2026-0001 - Potential Undefined Behaviors in `Arc<T>`/`Rc<T>` impls of `from_value` on OOM](https://junglewise.ai/threats/rustsec-2026-0001-potential-undefined-behaviors-in-arc-t-rc-t-impls-of-5dfbdf00)
