# zstd-safe use-after-free in CParameter::StableInBuffer

Source: https://junglewise.ai/threats/rustsec-2026-0395-use-after-free-with-cparameter-stableinbuffer-c8274f38  
Publisher: Junglewise Threat Intelligence, https://junglewise.ai/threats  
Published: 2026-10-16. Updated: 2026-10-28  
License: CC BY 4.0 with a link back

Severity: info · Published 2026-10-16

The zstd-safe Rust library, which provides safe bindings to the Zstandard compression library, contains a use-after-free vulnerability in its experimental StableInBuffer feature. When enabled, the underlying C library retains a pointer to input data from one call and reads it in subsequent operations, but safe Rust code may deallocate that memory between calls. An attacker could exploit this to read freed memory or cause a crash.

Technologies: [zstd-safe (crates.io)](https://junglewise.ai/threats/technologies/zstd-safe), [Gyscos Zstd-Safe](https://junglewise.ai/threats/technologies/gyscos-zstd-safe). Vendors: [crates.io](https://junglewise.ai/threats/vendors/crates-io), [Gyscos](https://junglewise.ai/threats/vendors/gyscos).

## 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?** Informational severity, published 16 October 2026.

**Which products and versions are affected?** zstd-safe (crates.io) SEMVER:introduced=4.1.0,fixed=8.2.0; Gyscos Zstd-Safe 4.1.0 to 8.1.x.

**Is there a fix for This vulnerability?** Yes. zstd-safe (crates.io): upgrade to 8.2.0 or later. Junglewise finds every place you run it, drafts the upgrade and applies it once you approve.

**How is This vulnerability attacked?** It is attacked with local access, in a software library.

**Am I affected?** Check whether you run zstd-safe (crates.io) or Gyscos Zstd-Safe 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.

## How to fix

- zstd-safe (crates.io): upgrade to 8.2.0 or later

  ```sh
  cargo update -p zstd-safe
  ```


## Technical details

The vulnerability exists in zstd_safe::CCtx::set_parameter when CParameter::StableInBuffer(true) is set. The C library keeps a pointer to the input buffer from a streaming call and accesses it in later calls (flush_stream, end_stream) that do not provide new input. Rust's InBuffer only borrows data for a single call, allowing safe code to deallocate it between calls; the freed memory may then be read during compression. The flaw affects all versions using the underlying zstd C library 1.5.4 or later.

## Affected products

- gyscos zstd-safe 4.1.0 to 8.1.x

## Timeline

- 2026-10-16: disclosed
- 2026-10-26: advisory
- 2026-10-26: patched: Fixed in zstd-safe 8.2.0 by refusing to enable the parameter

## References

- [https://crates.io/crates/zstd-safe](https://crates.io/crates/zstd-safe)
- [https://rustsec.org/advisories/RUSTSEC-2026-0395.html](https://rustsec.org/advisories/RUSTSEC-2026-0395.html)

## Related threats

- [zstd-safe use-after-free in multithreaded compression context](https://junglewise.ai/threats/rustsec-2026-0406-use-after-free-when-changing-a-multithreaded-context-0c474512)
- [zstd-safe double free in DCtx::try_clone](https://junglewise.ai/threats/rustsec-2026-0404-double-free-in-dctx-try-clone-108878f4)
- [zstd-safe Seekable decompress buffer overrun on invalid offset](https://junglewise.ai/threats/rustsec-2026-0398-seekable-decompress-sets-a-vec-length-beyond-its-2f278ece)
- [zstd-safe Seekable null or out-of-bounds seek table read](https://junglewise.ai/threats/rustsec-2026-0396-seekable-reads-a-null-or-out-of-bounds-seek-table-4b9e21ae)
- [zstd-safe use-after-free in dictionary decompression context](https://junglewise.ai/threats/rustsec-2026-0400-use-after-free-of-a-dictionary-after-a-one-shot-call-541157eb)
