Home/Research/Post

GHSA-72fp-85cc-g945: node-tar crashes the process with an uncaught exception on a 4-byte zstd magic header when the Node runtime lacks native zstd

  • Severity: HIGH
  • CVE: CVE-2026-140241
  • Ecosystems: npm
  • Packages: tar

### Summary
An unauthenticated remote-input denial of service allows a four-byte file to crash any process that lists or extracts it with node-tar’s asynchronous file API, on any Node runtime without native zlib zstd support (Node 18.x, 20.x, 21.x, 22.0-22.14, 23.0-23.7, all of which satisfy the package’s declared `engines: node >= 18`). node-tar’s default-enabled compression sniffing detects the zstd magic (`28 b5 2f fd`) and constructs `new ZstdDecompress({})` with no error handling. On a runtime without the zstd binding, minizlib’s constructor throws a `TypeError` synchronously inside the file-read stream’s data callback, so the async `tar.t()` / `tar.x()` promise never settles and the exception is uncaught, killing the process.

### Details
`Parser.write()` sniffs the first bytes of every input and, on the zstd magic, constructs the decompressor unguarded:

“`ts
// src/parse.ts:547-550
this[UNZIP] =
this[UNZIP] === undefined ? new Unzip({})
: isZstd ? new ZstdDecompress({}) // throws TypeError on a runtime without native zstd
: new BrotliDecompress({})
“`

`minizlib`’s `ZlibBase` constructor throws `TypeError: Compression method not supported: ZstdDecompress` when `node:zlib` lacks the binding. Because this construction runs inside the file-read stream’s `data` handler (`ReadStream.emit` -> `Unpack.write` -> `new ZstdDecompress`), the throw is not routed through the stream’s `error` event or `Parser.abort()`. For the async file form (`tar.x({file})` / `tar.t({file})`…

Source: GitHub Security Advisories · 2026-12-02