# RUSTSEC-2026-0401: Out-of-bounds read in `train_from_buffer` when sample sizes overflow

- Severity: not scored yet
- Known to be exploited: not in CISA's catalogue, which lists only what CISA has confirmed
- Published: 2026-10-16T12:00:00.000Z
- Modified: 2026-11-02T09:30:03.353Z

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

(As written by RustSec Advisory Database.)

## Affected

- zstd-safe (crates.io): from 0.0.0-0 before 7.4.0; from 8.0.0-0 before 8.2.0

## References

- <https://crates.io/crates/zstd-safe> (package)
- <https://rustsec.org/advisories/RUSTSEC-2026-0401.html> (advisory)
- <https://github.com/gyscos/zstd-rs/commit/781ea454191dbf178d09c1daf6fc896d15fbaa2f> (web)
- <https://github.com/gyscos/zstd-rs/pull/384> (web)

## Sources

- RustSec Advisory Database: [RUSTSEC-2026-0401](https://rustsec.org/advisories/RUSTSEC-2026-0401.html), CC0-1.0, modified 2026-11-02

---

Page: https://cve.day/RUSTSEC-2026-0401 · Whole record: https://cve.day/RUSTSEC-2026-0401.json · Rebuilt by cve.day 2026-11-25T22:56:43.451Z
