Skip to main content
← All vulnerabilities
RUSTSEC-2026-0395

Use-after-free with `CParameter::StableInBuffer`

Published
Last modified
published
Not listed in CISA KEV
Fix
Fixed in 8.2.0
None on Exploit-DB, Metasploit or GitHub

Summary

The Rust bindings for the zstd compression library (the `zstd-safe` crate) are affected when the experimental `StableInBuffer` option is enabled, and so is the underlying C zstd library, whether bundled or linked from the system. Memory that was already freed by the program can end up in compressed output, which could expose unrelated data from the program's memory.

Summarized by anthropic/claude-haiku-5.5. Verify details against the original sources.

Read the original description

With `CParameter::StableInBuffer(true)` (`experimental` feature), the C library keeps a pointer to the input of one streaming call and reads from it in later calls, including `flush_stream` and `end_stream`, which take no input. An `InBuffer` only borrows its slice for one call, so safe code could free it in between, and freed memory was compressed into the frame. The C library behaves this way since zstd 1.5.4, whether bundled or linked from the system. The flaw was corrected by refusing to enable the parameter.

Timeline

  1. Advisory published
  2. Record last updated

Affected versions

  • zstd-safecrates.io

    From 4.1.0 · fixed in 8.2.0

References 4

crates.io

rustsec.org

GitHub · gyscos/zstd-rs