medium

CVE

CVE-2026-124851

CWE

CWE-226, CWE-908

Affected Surface

  • Zstandard (zstd / libzstd) 1.5.1 through 1.5.7; fixed in 1.6.0 (23 November 2026)
  • Software that bundles a 1.5.x copy, including the Linux kernel (`lib/zstd`, 1.5.7, patch posted to LKML on 23 November 2026), Node.js (`deps/zstd`, 1.5.7) and Rust's `zstd-sys` crate (2.1.3+zstd.1.5.7)
  • Services that decompress zstd data from untrusted users with a reused decompression context and return or expose the decompressed output

TL;DR

Zstandard 1.5.1 through 1.5.7 can leak memory into decompressed output. According to Meta’s CVE record, specially crafted compressed data can expose the contents of an internal buffer, 64 KiB in the default configuration, that may hold uninitialized memory or literals from earlier decompressions on the same decompression context. An attacker who can submit compressed data and see what comes out can read that buffer.

The zstd maintainers released v1.6.0 at 22:55 UTC on 23 November 2026, ahead of schedule, because of this bug. The release notes say the team had been working through an “avalanche of reports received in the past few weeks”, most minor or duplicates, and that this one would be published as a CVE. Meta published CVE-2026-124851 at 23:20 UTC. It has no CVSS score and no credited reporter. The fix is PR #5023, a 35-line change to the block decoder.

The exposure depends on the deployment. heise’s example is a service that decompresses uploaded files and sends the result back to the sender. A multi-tenant service that reuses one decompression context across users could hand one user’s data to another. A command-line zstd -d on your own files isn’t a meaningful risk.

What to do now:

  1. Upgrade libzstd to 1.6.0, or to your distribution’s patched package when it ships. Debian lists zstd as unfixed and tracks it as bug 1155105.
  2. Find bundled copies. The Linux kernel, Node.js and Rust’s zstd-sys all carry 1.5.7 and need their own updates.
  3. Until you can patch, use a fresh decompression context per untrusted input and avoid echoing decompressed bytes from untrusted input back to the sender.

Affected packages and projects

EcosystemPackageAffected versionsFixed version
C library / CLIzstd / libzstd1.5.1 to 1.5.71.6.0
Linux kernellib/zstd (bundled 1.5.7)Kernels carrying zstd 1.5.1 to 1.5.7Patch posted to LKML on 23 November 2026, not yet merged
Node.jsdeps/zstd (bundled 1.5.7 on main)Releases bundling 1.5.1 to 1.5.7Not released yet as of 24 November 2026
Rust (crates.io)zstd-sysBuilds of the bundled source at zstd 1.5.1 to 1.5.7, including 2.1.3+zstd.1.5.7Not released yet as of 24 November 2026; linking a patched system libzstd avoids the bundled copy
DebianzstdAll releases shipping 1.5.1 to 1.5.7Unfixed (bug 1155105)

The GitHub Advisory Database has an unreviewed entry, GHSA-8hpw-86q9-rgx9, with no package listed. Any other binding or application that vendors zstd source inherits the bug if it bundles 1.5.1 to 1.5.7, so check which version each one embeds.

Technical analysis

What leaks

zstd’s decoder doesn’t always decode a block’s literals into a separate buffer. Depending on space, it stores them in spare room in the caller’s output buffer, in its own internal literal buffer, or split between the two. Match copies and literal copies use “wildcopy” routines that may read up to WILDCOPY_OVERLENGTH bytes past the end of the data they copy, which the code allows as long as those bytes are in owned memory.

The PR describes the bug like this:

After the streaming output buffer wraps, the external dictionary and current prefix must share the frame history window. Retaining expired history can allow malformed offsets to expose uninitialized bytes or literals from earlier decompressions on the same context.

In streaming mode the decoder keeps a history window split into two parts: the “prefix”, decoded output in the current contiguous segment, and the “external dictionary”, older output from before the buffer wrapped. Before the fix, the decoder kept the full external dictionary after a wrap even when part of it had expired out of the frame window. A malformed match offset that pointed into that expired region was accepted as in-window, and the bytes copied from it could be memory the decoder never wrote in this frame. That includes stale literals from a previous frame on the same context or uninitialized heap. The wildcopy over-read past the literal buffer could also pull in leftover bytes.

The fix

Merge commit 0c9d297531a9 makes two changes in lib/decompress/zstd_decompress_block.c. First, once a full window has been decoded, ZSTD_checkContinuity trims the external dictionary so prefix plus external history never exceed windowSize:

if (dstSize > 0 && dctx->isFrameDecompression && dctx->decodedSize > 0 && dctx->decodedSize >= dctx->fParams.windowSize) {
    size_t const prefixSize = (size_t)((const char*)dctx->previousDstEnd - (const char*)dctx->prefixStart);
    size_t const extDictSize = (size_t)((const char*)dctx->prefixStart - (const char*)dctx->virtualStart);
    U64 const maxExtDictSize = prefixSize < dctx->fParams.windowSize ? dctx->fParams.windowSize - prefixSize : 0;
    dctx->virtualStart = (const char*)dctx->prefixStart - (size_t)MIN((U64)extDictSize, maxExtDictSize);
}

Moving virtualStart forward shrinks the range that offset validation treats as valid history, so an offset into expired data now fails as corruption instead of copying stale bytes.

Second, a new helper zeroes the over-read zone after the decoded literals, in both halves when the literal buffer is split:

static void ZSTD_zeroLiteralsBufferPadding(ZSTD_DCtx* dctx, size_t litSize)
{
    if (dctx->litBufferLocation == ZSTD_split) {
        BYTE* const litBufferEnd = dctx->litBuffer + litSize - ZSTD_LITBUFFEREXTRASIZE;
        assert(litBufferEnd == dctx->litBufferEnd);
        ZSTD_memset(litBufferEnd, 0, WILDCOPY_OVERLENGTH);
        ZSTD_memset(dctx->litExtraBuffer + ZSTD_LITBUFFEREXTRASIZE, 0, WILDCOPY_OVERLENGTH);
    } else {
        BYTE* const litBufferEnd = dctx->litBuffer + litSize;
        assert(litBufferEnd == dctx->litBufferEnd);
        ZSTD_memset(litBufferEnd, 0, WILDCOPY_OVERLENGTH);
    }
}

It runs after each of the three literal decode paths (Huffman-compressed, raw and RLE), so permitted over-reads only ever see zeros. Nick Terrell posted the same 35-line change as a kernel patch against lib/zstd/decompress/zstd_decompress_block.c at 20:10 EST on 23 November.

Who is actually exposed

The CVE requires two things: the attacker controls compressed input, and the attacker can observe the decompressed output. Common patterns that meet both:

  • Upload, preview or conversion services that accept .zst files or Content-Encoding: zstd bodies and return or display the decompressed content.
  • Proxies, caches and API gateways that decompress client-supplied zstd and reflect parts of it back in responses or error messages.
  • Multi-tenant workers that keep a long-lived ZSTD_DCtx or ZSTD_DStream per thread and reuse it across requests from different users. This is the case where “literals from earlier decompressions” become someone else’s data.

Pure compression, decompression of data you produced yourself, and one-shot decompression into a freshly allocated context are much less interesting to an attacker, though upgrading is still the fix.

Other fixes in 1.6.0

The release also fixes a DDict hash table out-of-bounds read and write with ZSTD_d_refMultipleDDicts (#4731), a use-after-free of a ZSTD_DCtx_refPrefix() prefix after ZSTD_DCtx_reset() (#4848), an out-of-bounds read with ZSTD_c_stableInBuffer (#4943), a multithreaded compression use-after-free (#4871), memory corruption in ZSTD_compressSequences() (#4918, #4989, #5004) and an out-of-bounds write with ZSTD_c_targetCBlockSize (#4981). None of these has a CVE. 1.6.0 also turns off legacy format support (frames from zstd before 0.8.0) by default; set ZSTD_LEGACY_SUPPORT at build time if you still need to read them.

IOCs

This is a library vulnerability, not malware, so there are no network or file indicators. No public proof of concept or in-the-wild exploitation had been reported as of 24 November 2026, and the CVE is not in CISA KEV. Malformed frames that use match offsets reaching past the frame window are the input pattern to look for in fuzzing or decoder error logs; on 1.6.0 they fail with a corruption error.

Detection and remediation

Check the library version that is actually loaded, not only the CLI:

zstd --version
pkg-config --modversion libzstd
dpkg -l 'libzstd*' 2>/dev/null | grep ^ii
rpm -q libzstd 2>/dev/null
python3 -c "import ctypes,ctypes.util; l=ctypes.CDLL(ctypes.util.find_library('zstd')); l.ZSTD_versionString.restype=ctypes.c_char_p; print(l.ZSTD_versionString().decode())"

Find bundled copies in source trees and dependency graphs:

grep -rn --include=zstd.h -E '#define ZSTD_VERSION_(MAJOR|MINOR|RELEASE)' . | head
cargo tree -i zstd-sys 2>/dev/null
grep -n 'zstd-sys' Cargo.lock

Remediate:

  1. Update to zstd 1.6.0, or apply commit 0c9d297531a9f15a717ff24604afc0843b3b1427 to a vendored 1.5.x copy. It touches one file, lib/decompress/zstd_decompress_block.c.
  2. Rebuild static binaries and containers that embed libzstd. Updating the system package doesn’t fix a statically linked copy.
  3. For Rust, either wait for a zstd-sys release with 1.6.0 or build with the pkg-config feature against a patched system libzstd.
  4. Until you are patched, create a new decompression context per untrusted request, and don’t return raw decompressed output from untrusted input to the sender.

Timeline

  • 6 November 2026: The fix commit (d1b0cf9d64ea) is authored.
  • 9 November 2026: Meta reserves CVE-2026-124851.
  • 23 November 2026, 21:51 UTC: PR #5023 is merged into meta/zstd as 0c9d297531a9.
  • 23 November 2026, 22:55 UTC: Zstandard v1.6.0 is released.
  • 23 November 2026, 23:20 UTC: Meta publishes CVE-2026-124851 and its advisory.
  • 24 November 2026, 01:10 UTC (20:10 EST on 23 November): Nick Terrell posts the kernel port to LKML.
  • 24 November 2026: Davide Cavalca posts the CVE to oss-security; heise covers the release. Debian tracks zstd as unfixed (bug 1155105).

References

From research to remediation

Check whether this pattern exists in your codebase

Turn this research into a remediation workflow. Use AI-native static analysis to find similar application vulnerabilities and generate review-ready fixes.

References