# GHSA-vfvv-c25p-m7mm: Potential use-after-free due to lack of panic safety in `InlineVec::clear` and `SerVec::clear`

> A use-after-free vulnerability in rkyv allows memory corruption or double-free if a panic occurs during vector clearing, potentially leading to code execution.

- **Severity:** Not scored
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Not stated
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 23 Apr 2026
- **Also known as:** RUSTSEC-2026-0122

## What is GHSA-vfvv-c25p-m7mm?

GHSA-vfvv-c25p-m7mm is an use after free vulnerability in rkyv, published on 23 Apr 2026. 

### Official 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:

- `InlineVec::clear()` is called again from `InlineVec`'s own `Drop`
  implementation when the value is later dropped.
- `SerVec::clear()` is called again by `SerVec::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>` or `Vec<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.

## Which versions are affected by GHSA-vfvv-c25p-m7mm?

3 open source packages ship an affected version, including rkyv.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `rkyv` | crates.io | From 0.8.0 | 0.8.16 |
| `rkyv` | crates.io | From 0.8.0 | 0.8.16 |
| `rkyv` | crates.io | From 0.8.0 | 0.8.16 |

## How do I fix GHSA-vfvv-c25p-m7mm?

Upgrade rkyv to 0.8.16 or later.

## Is GHSA-vfvv-c25p-m7mm being exploited?

There is no known exploitation of GHSA-vfvv-c25p-m7mm in the wild and no public exploit code.

## Fix prompt for AI coding agents

```text
Check this codebase for GHSA-vfvv-c25p-m7mm and fix it if it is affected.

What it is: GHSA-vfvv-c25p-m7mm is an use after free vulnerability in rkyv, published on 23 Apr 2026. 
Exploitation: There is no known exploitation of GHSA-vfvv-c25p-m7mm in the wild and no public exploit code.

Affected packages and fixed versions:
- rkyv (crates.io): affected from 0.8.0; fixed in 0.8.16
- rkyv (crates.io): affected from 0.8.0; fixed in 0.8.16
- rkyv (crates.io): affected from 0.8.0; fixed in 0.8.16

Task:
1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.
2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.
3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.
4. Run the tests and summarise what changed and why.
5. If nothing in the project is affected, say so and change nothing.

Reference: https://insights.sbomify.com/GHSA-vfvv-c25p-m7mm/ (Markdown: https://insights.sbomify.com/GHSA-vfvv-c25p-m7mm/index.md)
```

## Sources

- OSV: https://osv.dev/vulnerability/GHSA-vfvv-c25p-m7mm

---
From sbomify Insights: https://insights.sbomify.com/GHSA-vfvv-c25p-m7mm/
Summaries are generated and may contain mistakes; the official description above is the record.
