CVEReports
CVEReports

Automated vulnerability intelligence platform. Comprehensive reports for high-severity CVEs generated by AI.

Product

  • Home
  • Sitemap
  • RSS Feed

Company

  • About
  • Contact
  • Privacy Policy
  • Terms of Service

© 2026 CVEReports. All rights reserved.

Made with love by Amit Schendel & Alon Barad



CVE-2026-140241

CVE-2026-140241: Uncaught Exception Denial of Service in node-tar via Zstandard Magic Header

Alon Barad
Alon Barad
Software Engineer

Dec 2, 2026·10 min read·5 visits

Executive Summary (TL;DR)

An uncaught synchronous TypeError during Zstandard decompressor instantiation in node-tar (versions 7.5.22 to 7.5.24) allows unauthenticated attackers to crash the Node.js process using a 4-byte file containing the zstd magic header on runtimes without native zstd support.

CVE-2026-140241 is a Denial of Service (DoS) vulnerability in the node-tar archive manipulation library (npm package: tar) affecting versions 7.5.22 through 7.5.24. The defect stems from an uncaught synchronous exception thrown during the initialization of Zstandard (zstd) decompression on Node.js runtimes that lack native zstd bindings. An unauthenticated attacker can supply a 4-byte payload containing the zstd magic header (0x28 0xb5 0x2f 0xfd) to asynchronous listing or extraction APIs, causing the error to escape stream event handlers and terminate the Node.js process.

Vulnerability Overview

The node-tar library (published to the npm registry as tar) is a widely deployed archive manipulation utility in the Node.js ecosystem. It provides high-level stream and file system APIs for creating, listing, and extracting tar archives, including automated decompression of compressed streams. Because archive ingestion is frequently exposed to untrusted external inputs—such as package managers, file upload handlers, and CI/CD artifact processors—the parsing engine represents a critical attack surface.

In version 7.5.22, node-tar introduced automated detection and decompression for Zstandard (zstd) compressed archives via its underlying streaming decompression dependency, minizlib. When an incoming byte stream is passed to the parser, node-tar inspects the leading magic bytes of the data buffer to identify the compression algorithm before passing the decompressed tar blocks to the entry processor.

CVE-2026-140241 (also tracked as GHSA-72fp-85cc-g945) is classified under CWE-248 (Uncaught Exception) and CWE-755 (Improper Handling of Exceptional Conditions). When node-tar processes a stream prefixed with the 4-byte Zstandard magic signature (0x28 0xb5 0x2f 0xfd), it synchronously instantiates the ZstdDecompress class from minizlib. On Node.js runtimes that do not compile or expose native Zstandard bindings in the internal zlib module, the constructor throws a synchronous TypeError.

Because this instantiation occurs inside an asynchronous file stream read callback without an enclosing try...catch block, the exception is neither emitted as a stream error event nor converted into a Promise rejection. Consequently, the unhandled exception propagates directly to the top-level Node.js event loop, immediately terminating the host application process and causing a complete Denial of Service (DoS).

Root Cause Analysis

The root cause of CVE-2026-140241 lies in an architectural mismatch between synchronous exception throwing in minizlib and asynchronous event-driven error propagation in node-tar's Parser class. In Node.js stream architectures, errors occurring during chunk transformation must be caught and forwarded to the stream's error emitter (this.emit('error', err)) or handled via an abort routine so that downstream consumers and Promise wrappers can intercept them.

When node-tar processes input through high-level asynchronous functions such as tar.x() (extract) or tar.t() (list) with a file parameter, it opens an underlying file descriptor and creates a readable file stream. As the libuv I/O loop reads chunks from disk, it invokes the 'data' event listener attached to the stream, which subsequently calls internal chunk consumption routines in src/parse.ts.

During the initial chunk evaluation inside Parser, the parser buffers the first few bytes of the file and checks for compression magic numbers: 0x1f 0x8b for Gzip, or 0x28 0xb5 0x2f 0xfd for Zstandard. Once the Zstandard header is matched, the isZstd flag evaluates to true, and the parser attempts to initialize the decompressor pipe by calling new ZstdDecompress({}).

In minizlib, ZstdDecompress wraps the host Node.js runtime's native zlib bindings. If the active Node.js runtime (such as Node.js 18.x, 20.x, or early 22.x builds without native zstd support) lacks the underlying native binding, minizlib immediately throws new TypeError('Compression method not supported: ZstdDecompress') from its constructor. Because node-tar invoked new ZstdDecompress({}) directly inside the stream chunk handler without exception handling, the synchronous throw bypasses both the Parser error event listeners and the try...catch block of any caller awaiting the tar.x() or tar.t() Promise.

Code Analysis

In versions 7.5.22 through 7.5.24, the vulnerable decompressor initialization logic resides in src/parse.ts within the Parser class. When the parser detects that decompression has not yet been initialized (this[UNZIP] === undefined) or needs to switch to Brotli or Zstandard, it executes a ternary expression to instantiate the appropriate decompressor class.

// Vulnerable code in src/parse.ts prior to commit 73b352e0010d6c99794ea7374800816a46d3bdb2
if (
  this[UNZIP] === undefined ||
  (this[UNZIP] === false && (this.brotli || isZstd))
) {
  const ended = this[ENDED]
  this[ENDED] = false
  // VULNERABLE: Synchronous constructor call without try/catch.
  // If isZstd is true on a Node.js runtime lacking native zstd support,
  // new ZstdDecompress({}) throws a synchronous TypeError that escapes the stream.
  this[UNZIP] =
    this[UNZIP] === undefined ? new Unzip({})
    : isZstd ? new ZstdDecompress({})
    : new BrotliDecompress({})
  this[UNZIP].on('data', chunk => {
    if (this[CHECKDECOMPRESSIONRATIO](chunk)) {
      this[CONSUMECHUNK](chunk)
    }
  })
  // ...
}

To remediate this flaw in commit 73b352e0010d6c99794ea7374800816a46d3bdb2, the maintainer wrapped the ternary decompressor assignment in a try...catch block. If any decompressor constructor throws an exception during instantiation, the catch block intercepts the error, transitions the parser into an aborted state via this.abort(er as Error), invokes the optional completion callback cb?.(), and returns false to halt further chunk processing cleanly.

--- a/src/parse.ts
+++ b/src/parse.ts
@@ -544,10 +544,17 @@ export class Parser extends EE implements Warner {
       ) {
         const ended = this[ENDED]
         this[ENDED] = false
-        this[UNZIP] =
-          this[UNZIP] === undefined ? new Unzip({})
-          : isZstd ? new ZstdDecompress({})
-          : new BrotliDecompress({})
+        try {
+          this[UNZIP] =
+            this[UNZIP] === undefined ? new Unzip({})
+            : isZstd ? new ZstdDecompress({})
+            : new BrotliDecompress({})
+        } catch (er) {
+          // Intercepts synchronous constructor errors (e.g., missing native zstd support)
+          // and forwards them to the Parser stream error handler.
+          this.abort(er as Error)
+          cb?.()
+          return false
+        }
         this[UNZIP].on('data', chunk => {
           if (this[CHECKDECOMPRESSIONRATIO](chunk)) {
             this[CONSUMECHUNK](chunk)

Following this targeted fix, node-tar underwent a broader architectural overhaul in commit 634eea74d893808fcf297272d6bbdaeedd69d3f4 for the release of version 8.0.0. In version 8.0.0, the legacy dependencies minizlib, minipass, and @isaacs/fs-minipass were removed entirely in favor of Web Standard DecompressionStream primitives and explicit pluggable Codec handlers, while raising the minimum required Node.js engine version to >= 22.

The fix in commit 73b352e0010d6c99794ea7374800816a46d3bdb2 and the subsequent v8.0.0 release completely address the issue. By catching synchronous constructor exceptions at the stream boundary and routing them through this.abort(), any unsupported compression error is properly emitted as an 'error' event on the Parser instance, causing awaiting Promises to reject cleanly rather than crashing the process.

Exploitation

Exploiting CVE-2026-140241 requires no authentication or specialized privileges, provided the target application exposes an endpoint or pipeline that passes user-supplied files or byte streams to node-tar for extraction (tar.x / tar.extract) or inspection (tar.t / tar.list). Furthermore, the target application must be executing on a Node.js runtime environment that lacks native Zstandard support in its internal zlib module.

The payload required to trigger the crash does not need to be a valid tar archive or a valid Zstandard compressed stream. Because node-tar inspects the magic header before attempting to decompress the payload body, a file containing only the 4-byte Zstandard frame magic number (0x28 0xb5 0x2f 0xfd) is sufficient to reach the vulnerable code path.

# Generate the minimal 4-byte payload containing the zstd magic header
printf '\x28\xb5\x2f\xfd' > crash_poc.tar

When a vulnerable application processes this 4-byte file using standard async/await error handling around tar.t() or tar.x(), the try...catch block in the application code fails to catch the exception. The stream reader reads the 4 bytes asynchronously from the file descriptor, invokes the parser chunk callback on a separate tick of the event loop, and triggers the uncaught synchronous TypeError.

import tar from 'tar';
 
async function processUntrustedArchive() {
  try {
    // Attempt to list archive contents asynchronously
    await tar.t({
      file: 'crash_poc.tar'
    });
  } catch (err) {
    // This catch block is bypassed entirely in tar versions 7.5.22 - 7.5.24
    console.error('Handled archive error:', err.message);
  }
}
 
processUntrustedArchive();

> [!NOTE] > The commit 73b352e0010d6c99794ea7374800816a46d3bdb2 includes a regression unit test in test/resource-limits.test.ts that reproduces this exact condition by mocking minizlib.ZstdDecompress to throw TypeError('Compression method not supported') upon receiving a 512-byte buffer starting with [0x28, 0xb5, 0x2f, 0xfd].

Impact Assessment

The primary security impact of CVE-2026-140241 is a high-severity Denial of Service (DoS) against the availability of the host Node.js process. In Node.js applications, a single main thread services the event loop for all concurrent client connections. When an uncaughtException reaches the top level of the event loop without a global process exception handler, the Node.js runtime immediately prints a stack trace and exits with code 1.

This behavior allows an unauthenticated attacker to repeatedly terminate backend web servers, API gateways, artifact repositories, or background worker daemons by submitting a 4-byte payload. Even if the deployment utilizes a process supervisor (such as PM2, systemd, or Kubernetes pod restart policies), an attacker can send continuous low-bandwidth requests to keep the service in a perpetual crash loop, dropping all active connections and in-flight transactions.

The vulnerability is assigned a CVSS v4.0 base score of 7.1 (High) with the vector CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:P/VC:N/VI:N/VA:H/SC:N/SI:N/SA:N. The Attack Vector is Network (AV:N) and Attack Complexity is Low (AC:L), reflecting the trivial nature of constructing and transmitting the 4-byte magic sequence. Attack Requirements are None (AT:N) and Privileges Required are None (PR:N). User Interaction is rated Passive (UI:P), indicating that the vulnerable software component processes input provided through normal application workflows.

The impact metrics reflect total loss of availability on the vulnerable system (VA:H), with no direct impact on confidentiality (VC:N), integrity (VI:N), or subsequent downstream systems (SC:N/SI:N/SA:N). At the time of publication, CVE-2026-140241 is not listed in the CISA Known Exploited Vulnerabilities (KEV) catalog.

Remediation

To remediate CVE-2026-140241, developers and system administrators should upgrade the tar package to version 8.0.0 or later. Version 8.0.0 incorporates both the synchronous exception handling fix and a complete architecture migration to Web Standard streams.

npm install tar@^8.0.0

> [!NOTE] > Upgrading to tar version 8.0.0 introduces breaking changes: it requires Node.js version 22 or higher, replaces legacy EventEmitter stream patterns with Promise-based APIs and Web ReadableStream primitives, and moves Node.js-specific synchronous file system operations (such as extractSync) to the tar/node sub-path export.

For environments that cannot immediately migrate to tar v8.0.0 due to the Node.js >= 22 engine constraint, two alternative mitigations exist:

  1. Upgrade the Node.js Runtime Environment: Ensure the underlying Node.js runtime includes native Zstandard support in its built-in node:zlib module. When native zstd bindings are present, minizlib's ZstdDecompress constructor succeeds rather than throwing TypeError: Compression method not supported, and malformed 4-byte archives will instead fail gracefully as regular stream truncation errors.
  2. Pre-Validate Magic Bytes Before Extraction: Implement an application-layer check to inspect the first 4 bytes of any untrusted file or stream before passing it to tar.x() or tar.t(). If the leading bytes match 0x28 0xb5 0x2f 0xfd on a runtime lacking native zstd support, reject the file prior to invoking node-tar.
import fs from 'node:fs';
import tar from 'tar';
 
const ZSTD_MAGIC = Buffer.from([0x28, 0xb5, 0x2f, 0xfd]);
 
function hasZstdHeader(filePath) {
  const fd = fs.openSync(filePath, 'r');
  try {
    const buffer = Buffer.alloc(4);
    const bytesRead = fs.readSync(fd, buffer, 0, 4, 0);
    return bytesRead === 4 && buffer.equals(ZSTD_MAGIC);
  } finally {
    fs.closeSync(fd);
  }
}
 
export async function safeExtract(filePath, options = {}) {
  if (hasZstdHeader(filePath)) {
    throw new Error('Unsupported archive format: Zstandard compression is disabled.');
  }
  return await tar.x({ ...options, file: filePath });
}

Official Patches

GitHub / isaacsOfficial commit adding try/catch exception handling around ZstdDecompress instantiation in src/parse.ts
GitHub / isaacsnode-tar v8.0.0 release notes
GitHub Security AdvisoryOfficial GitHub Security Advisory GHSA-72fp-85cc-g945

Fix Analysis (1)

Technical Appendix

CVSS Score
7.1/ 10
CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:P/VC:N/VI:N/VA:H/SC:N/SI:N/SA:N

Affected Systems

node-tar (npm package: tar) >= 7.5.22, < 8.0.0

Affected Versions Detail

Product
Affected Versions
Fixed Version
tar (node-tar)
isaacs
>= 7.5.22, < 8.0.08.0.0
AttributeDetail
CVE / Advisory IDCVE-2026-140241 / GHSA-72fp-85cc-g945
Primary CWECWE-248 (Uncaught Exception) / CWE-755
CVSS v4.0 Score7.1 High (CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:P/VC:N/VI:N/VA:H/SC:N/SI:N/SA:N)
Attack VectorNetwork (4-byte Zstandard magic header 0x28 0xb5 0x2f 0xfd)
Affected Versionstar >= 7.5.22, < 8.0.0 (7.5.22, 7.5.23, 7.5.24)
Patched Versiontar 8.0.0
ImpactImmediate Node.js process crash (Denial of Service)
CISA KEV StatusNot Listed

MITRE ATT&CK Mapping

T1499Endpoint Denial of Service
Impact
CWE-248
Uncaught Exception

An exception is thrown during program execution that is not caught or handled, resulting in abnormal application termination.

Vulnerability Timeline

Vulnerability observed and addressed in the isaacs/node-tar repository.
2026-11-26
Fix commit 73b352e0010d6c99794ea7374800816a46d3bdb2 and v8.0.0 redesign commit 634eea74d893808fcf297272d6bbdaeedd69d3f4 merged to main.
2026-11-27
GitHub Security Advisory GHSA-72fp-85cc-g945 and CVE-2026-140241 officially published.
2026-12-01

References & Sources

  • [1]GitHub Security Advisory: GHSA-72fp-85cc-g945
  • [2]Official Fix Commit in isaacs/node-tar
  • [3]node-tar Release v8.0.0 Notes
  • [4]NVD CVE-2026-140241 Detail
  • [5]CVE.org Record: CVE-2026-140241
  • [6]cvelistV5 Raw Advisory JSON for CVE-2026-140241

Attack Flow Diagram

Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.
Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.

More Reports

•about 1 hour ago•CVE-2026-140244
7.2

CVE-2026-140244: Symlink Containment Bypass and Arbitrary File Read in node-tar

CVE-2026-140244 (GHSA-mhqm-9wj8-w7r4) is a symlink containment bypass vulnerability in node-tar prior to version 8.0.0. Because the archive unpacker validates symbolic link targets using purely lexical path normalization without accounting for intermediate archive-created symlinks, an attacker can craft a tar archive containing chained symlinks that resolve outside the extraction directory on the physical filesystem. Downstream applications that read, copy, serve, or re-archive the extracted directory tree follow these planted symlinks, resulting in arbitrary file read and information disclosure.

Amit Schendel
Amit Schendel
1 views•13 min read
•about 2 hours ago•CVE-2026-140242
7.1

CVE-2026-140242: Improper Input Validation in node-tar PAX Header Parser Causes Entry Loss and Denial of Service

CVE-2026-140242 (also tracked as GHSA-ph3c-p786-j4rp) is an input validation vulnerability (CWE-1284) in the node-tar package for Node.js, affecting versions >= 7.0.0 and < 7.5.24. The parser for POSIX.1-2001 Extended (PAX) header records fails to verify that the parsed value of the size attribute is a finite, safe integer. Supplying a PAX header record with a size value such as Infinity bypasses simple non-negative numerical checks via JavaScript unary coercion. This results in stream boundary corruption and entry loss during archive extraction, or an uncaught runtime exception and process termination when re-packing the archive.

Alon Barad
Alon Barad
3 views•11 min read
•about 4 hours ago•CVE-2026-140240
7.1

CVE-2026-140240: Resource Exhaustion and Algorithmic Complexity Denial of Service in node-tar

CVE-2026-140240 (GHSA-7c32-79xj-j3jp) is a resource exhaustion and algorithmic complexity vulnerability in node-tar, the archive manipulation library for Node.js. In versions prior to 8.0.2, processing a small, crafted tar archive (approximately 20 KB) causes severe CPU degradation or triggers an Out-of-Memory (OOM) crash in the V8 JavaScript heap. The vulnerability stems from quadratic string allocation in asynchronous path reservation bookkeeping, unbounded depth and length validation on linkpath headers, memory retention leaks in reservation maps, and unbounded string caching in the Unicode normalization subsystem.

Alon Barad
Alon Barad
6 views•10 min read
•about 5 hours ago•CVE-2026-140239
7.2

CVE-2026-140239: Global Extended Header linkpath Injection in node-tar

CVE-2026-140239 (GHSA-ffhw-4r4q-5cwv) is an improper input validation vulnerability in the node-tar npm package prior to version 8.0.0. An inconsistency between the Header and ReadEntry parsing classes allows an attacker to inject an arbitrary linkpath attribute into all subsequent archive entries via a PAX Global Extended Header (type 'g'). Because the Header class ignores the global linkpath while ReadEntry applies it, the parser's strict-mode integrity validation is bypassed, enabling downstream applications that inspect entry.linkpath to be manipulated into arbitrary file read or write operations outside the extraction directory.

Alon Barad
Alon Barad
7 views•12 min read
•about 6 hours ago•CVE-2026-140238
7.2

CVE-2026-140238: PAX Extended Header Newline Injection and File Overwrite in node-tar

CVE-2026-140238 (GHSA-mpg7-vg3p-wc3m) is a high-severity parsing vulnerability in node-tar versions prior to 8.0.0. By splitting POSIX.1-2001 PAX extended header blocks on raw newline characters instead of enforcing byte-length framing prefixes, the parser allows unescaped newlines within metadata fields to inject forged PAX records. Attackers can override entry attributes such as file paths during extraction, enabling arbitrary file overwrites inside the destination directory and remote code execution on Windows via npm lifecycle script injection.

Alon Barad
Alon Barad
4 views•14 min read
•about 7 hours ago•CVE-2026-140237
6.9

CVE-2026-140237: PAX Metadata-Body File Smuggling and Interpretation Conflict in node-tar

An interpretation conflict vulnerability in node-tar versions 7.0.0 prior to 8.0.0 allows attackers to smuggle arbitrary tar archive members inside POSIX extended header (PAX) metadata blocks. Because node-tar reapplied pending PAX size attributes onto subsequent metadata entries, an attacker can set a PAX size of zero to prematurely terminate metadata body consumption. When combined with multi-engine inspection and extraction pipelines, this parser desynchronization permits file smuggling that bypasses archive member allowlists, malware scanning, and security policy verification.

Amit Schendel
Amit Schendel
9 views•12 min read