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-140240

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

Alon Barad
Alon Barad
Software Engineer

Dec 2, 2026·10 min read·6 visits

Executive Summary (TL;DR)

A flaw in node-tar versions prior to 8.0.2 allows unauthenticated attackers to crash Node.js applications via Out-of-Memory (OOM) errors or CPU exhaustion using a 20 KB crafted tar archive. Upgrading to tar@8.0.2 resolves the issue by refactoring path reservations into a Trie structure and enforcing strict path length and depth bounds.

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.

Vulnerability Overview

node-tar (distributed via the npm package tar) is a widely deployed archive creation, listing, and extraction library for the Node.js ecosystem. It serves as a foundational component in package managers, build pipelines, deployment automation services, and web applications that ingest archive uploads.

CVE-2026-140240 (also tracked as GHSA-7c32-79xj-j3jp) is an algorithmic complexity and uncontrolled resource consumption vulnerability affecting all versions of node-tar prior to 8.0.2. When an application extracts or lists the contents of an untrusted tar archive asynchronously, it relies on internal path reservation and normalization mechanisms to coordinate concurrent filesystem operations safely.

Due to multiple compounding flaws—classified under CWE-407 (Inefficient Algorithmic Complexity), CWE-401 (Missing Release of Memory after Effective Lifetime), and CWE-770 (Allocation of Resources Without Limits or Throttling)—an attacker can supply a compact archive (as small as 20 KB) that triggers asymmetric memory allocation and CPU consumption.

Processing these crafted entries forces the V8 engine to allocate hundreds of megabytes of heap memory for intermediate path strings and cache entries. This rapid memory growth results in an immediate Out-of-Memory (OOM) fatal process termination or an application deadlock, denying availability to the host service.

Root Cause Analysis

The root cause of CVE-2026-140240 involves six distinct implementation flaws across the extraction, path reservation, Unicode normalization, and file filtering subsystems of node-tar.

First, node-tar lacked depth and character length validation on symbolic and hard link targets (linkpath). While prior security patches enforced a maxDepth limit (defaulting to 1,024 levels) on entry.path, entry.linkpath—populated via standard ustar headers or PAX @LongLink records—remained unchecked. Furthermore, neither path nor linkpath enforced an upper ceiling on character length. When reserving filesystem paths for concurrency, the unpack engine inspected every ancestor directory of both path and linkpath, allowing deeply nested linkpaths (such as a/ repeated thousands of times) to force exhaustive ancestor traversal.

Second, the PathReservations class exhibited quadratic memory allocation ($O(N \times L)$) when locking parent directories. To prevent race conditions during asynchronous extraction, PathReservations tracks exclusive locks on target paths and shared locks on all parent directories. The pre-patch implementation generated parent directory paths by repeatedly calling path.slice(0, i) at every / delimiter and storing each resulting substring as a distinct string key in a flat JavaScript Map (#queues). For a single path containing 1,024 segments spanning 32,767 characters, slicing and storing every prefix substring consumed approximately 17 MB of V8 heap memory. Extracting just 16 such entries allocated over 270 MB, exhausting default Node.js heap limits.

Third, PathReservations.#clear() contained a state retention leak. When an asynchronous extraction callback completed, #clear() deleted the task reference from this.#running but failed to delete the corresponding entry from this.#reservations. Consequently, all reservation sets and associated path references remained pinned in memory for the entire duration of the unpack operation.

Fourth, the global Unicode normalization cache in src/normalize-unicode.ts enforced a maximum entry count (MAX = 10000) but placed no restriction on individual string byte lengths. By supplying archives with 32 KiB path strings, an attacker could populate the global cache with up to 10,000 long strings, permanently retaining upwards of 380 MB of memory across the lifetime of the Node.js process.

Fifth, relative link handling in PathReservations contained a self-deadlock condition where an entry whose linkpath resolved to a direct parent or descendant of its own path caused the asynchronous reservation queue to wait indefinitely on its own lock. Finally, when callers utilized a custom file filter via filesFilter in src/list.ts, the filter memoized parent directory checks in a persistent map (map.set(file, ret)), causing monotonic memory consumption proportional to the number of unique path prefixes.

Code Analysis

The remediation was implemented across two primary commits: 73b352e0010d6c99794ea7374800816a46d3bdb2 and de87900752566867b422de0ebfe6592b30fa9786. The fixes introduce strict input boundaries, replace flat string maps with a pruned Trie structure, and constrain global cache growth.

In src/unpack.ts, the patch introduces a hard ceiling of 32,768 characters (MAX_PATH_LENGTH) for both path and linkpath, and extends the existing maxDepth check to cover linkpath:

const DEFAULT_MAX_DEPTH = 1024
const MAX_PATH_LENGTH = 32768
 
// Validate linkpath depth against maxDepth
const { linkpath } = entry
if (
  linkpath &&
  isFinite(this.maxDepth) &&
  normalizeWindowsPath(linkpath).split('/').length > this.maxDepth
) {
  this.warn('TAR_ENTRY_ERROR', 'linkpath excessively deep', {
    entry,
    path: p,
    linkpath,
    maxDepth: this.maxDepth,
  })
  return false
}
 
// Validate absolute character length for both path and linkpath
for (const field of ['path', 'linkpath'] as const) {
  const { length } = entry[field] ?? ''
  if (length > MAX_PATH_LENGTH) {
    this.warn('TAR_ENTRY_ERROR', `${field} excessively long`, {
      entry,
      path: p,
      length,
      maxLength: MAX_PATH_LENGTH,
    })
    return false
  }
}

In src/path-reservations.ts, the vulnerable getDirs prefix-slicing function and flat #queues Map were completely removed. In the vulnerable implementation, parent directories were computed and stored as full prefix copies:

// VULNERABLE: Creates O(N * L) string slices in memory
const getDirs = (path: string) => {
  const dirs: string[] = []
  for (let i = path.indexOf('/'); i !== -1; i = path.indexOf('/', i + 1)) {
    dirs.push(path.slice(0, i) || '/')
  }
  return dirs
}

The patched implementation replaces this with a hierarchical Trie composed of Node objects. Each path segment is stored once as an individual token, reducing space complexity from $O(N \times L)$ to $O(L)$:

// PATCHED: Trie node representation for path segments
type Node = {
  queue: Queue
  name: string
  up?: Node
  kids?: Map<string, Node>
}
type Reservation = { paths: Set<Node>; dirs: Set<Node> }

Additionally, PathReservations.#clear() was updated to actively prune unused leaf nodes bottom-up once their task queues empty, and to delete the completed callback fn from this.#reservations:

// PATCHED: Active Trie pruning and reservation map cleanup
for (let node of paths) {
  while (node.up && !node.queue.length && !node.kids?.size) {
    node.up.kids?.delete(node.name)
    node = node.up
  }
}
this.#running.delete(fn)
this.#reservations.delete(fn) // Fixes memory retention leak

In src/normalize-unicode.ts, a MAX_LENGTH = 256 constant was added to bypass the global cache for abnormally long path segments:

const MAX_LENGTH = 256
export const normalizeUnicode = (s: string): string => {
  if (s.length > MAX_LENGTH) {
    return s
      .normalize('NFD')
      .toLocaleLowerCase('en')
      .toLocaleUpperCase('en')
  }
  // Proceed with bounded caching for strings <= 256 characters

> [!NOTE] > Fix Completeness Assessment: The combination of commits 73b352e0010d6c99794ea7374800816a46d3bdb2 and de87900752566867b422de0ebfe6592b30fa9786 comprehensively addresses the identified exhaustion vectors. By bounding path lengths to 32 KiB, enforcing depth limits on link targets, eliminating prefix string duplication via a self-pruning Trie, and capping cached Unicode strings at 256 bytes, the worst-case memory footprint per concurrent task is strictly bounded.

Exploitation

Exploiting CVE-2026-140240 requires no authentication or specialized privileges. The attacker only needs to supply a crafted tar archive to an application that extracts (tar.x / Unpack) or lists (tar.t / List) archives using node-tar. Because tar headers compress efficiently and repeat structures easily, a payload capable of crashing a standard Node.js runtime requires roughly 20 KB.

Two primary proof-of-concept vectors were documented in the official repository regression suite to demonstrate the resource exhaustion mechanics.

Vector 1: Deep linkpath Traversal via @LongLink

By constructing a GNU tar @LongLink header (type: 'NextFileHasLongLinkpath'), an attacker can specify a linkpath that bypasses standard 100-byte ustar header limitations and contains thousands of directory levels:

const ent = (h, body = '') => {
  /* Standard 512-byte padded tar header generator */
}
const longLink = (name) =>
  ent({ path: '././@LongLink', type: 'NextFileHasLongLinkpath' }, name + '\0')
 
// Construct an archive with a linkpath exceeding the 1024 maxDepth limit
const maliciousArchive = [
  longLink('a/'.repeat(1024) + 'x'),
  ent({ path: 'ln', type: 'SymbolicLink', linkpath: 'p' })
]

When an unpatched version of node-tar processes this archive, it fails to reject the deep linkpath, passing the 1,025-segment path directly into the path reservation and normalization routines.

Vector 2: Heap Exhaustion via Prefix Duplication

To trigger an Out-of-Memory crash within the PathReservations engine, an attacker packs 16 entries where each entry's path consists of 1,024 directory segments, each padded to 31 characters (totaling ~32,767 characters per entry path, which fits just below the 1,024 maxDepth threshold):

const path = (i) =>
  Array.from({ length: 1024 }, () => `${i}`.padEnd(31, 'b')).join('/')
 
const r = new PathReservations()
for (let i = 0; i < 16; i++) {
  r.reserve([path(i)], async () => {
    /* Hold asynchronous reservation lock */
  })
}

During asynchronous extraction, these 16 entries are queued concurrently. For each entry, getDirs() slices 1,024 progressively longer prefix strings (from 31 bytes up to 32,767 bytes), allocating roughly 17 MB of string data per entry. Across 16 entries, the heap allocation exceeds 270 MB before extraction completes, crashing any Node.js process running with constrained container memory limits (such as 256 MB or 512 MB cloud functions).

Impact Assessment

The primary impact of CVE-2026-140240 is a high-severity Denial of Service (DoS) against the vulnerable Node.js process. In CVSS v4.0, the vulnerability carries a 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.

Because Node.js utilizes a single-threaded event loop and a shared V8 heap space by default, an Out-of-Memory fatal exception or an event-loop stall during archive processing terminates the entire application process. In multi-tenant web applications, CI/CD runners, or package registry backends, an unauthenticated user uploading a single 20 KB archive can repeatedly crash worker processes, disrupting service for all concurrent users.

Even if the immediate extraction does not exceed the V8 --max-old-space-size ceiling and crash the process, the unbounded byte retention in the global normalizeUnicode cache allows an attacker to gradually degrade available memory across multiple separate requests until the process eventually exhausts system memory.

No confidentiality (VC:N) or integrity (VI:N) compromises are possible through this flaw, as the vulnerability strictly affects memory allocation, garbage collection lifecycle, and lock reservation concurrency.

Remediation

To remediate CVE-2026-140240, organizations must upgrade node-tar (tar) to version 8.0.2 or later. Version 8.0.2 incorporates both the input validation bounds on path and linkpath and the Trie-based memory refactor for PathReservations.

Administrators and developers should update their dependency manifests (package.json) and lockfiles using npm:

npm install tar@>=8.0.2

Because tar is frequently included as a transitive dependency by build tools, CLI frameworks, and bundler packages, security teams should audit their full dependency trees to verify that no older 7.x or 8.0.0/8.0.1 instances remain installed:

npm ls tar

If transitive dependencies pin tar to an older major version (such as < 8.0.0) and cannot be immediately upgraded, teams can utilize the overrides field in package.json (or resolutions in Yarn) to force resolution to 8.0.2 after testing for API compatibility.

> [!NOTE] > Workarounds for Unpatched Environments: Note that simple HTTP upload file-size limits are ineffective against CVE-2026-140240 because a 20 KB archive is sufficient to trigger heap exhaustion. If an immediate upgrade is impossible, isolate untrusted archive operations inside ephemeral worker processes or restricted containers with strict execution timeouts and process supervision, or switch to synchronous extraction (tar.x({ sync: true })) where architecturally feasible to bypass the asynchronous PathReservations queue.

Official Patches

GitHub / isaacsOfficial node-tar v8.0.2 release containing the fixes for CVE-2026-140240.
GitHub Security AdvisoryOfficial GitHub Security Advisory GHSA-7c32-79xj-j3jp.

Fix Analysis (2)

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) < 8.0.2

Affected Versions Detail

Product
Affected Versions
Fixed Version
tar (node-tar)
isaacs
< 8.0.28.0.2
AttributeDetail
CVE IDCVE-2026-140240 (GHSA-7c32-79xj-j3jp)
Weakness ClassCWE-407 / CWE-401 / CWE-770 (Algorithmic Complexity & Memory Exhaustion)
CVSS v4.0 Score7.1 High (AV:N/AC:L/AT:N/PR:N/UI:P/VC:N/VI:N/VA:H/SC:N/SI:N/SA:N)
Attack VectorNetwork (Untrusted Tar Archive Processing)
ImpactDenial of Service via V8 Out-of-Memory (OOM) Crash or Lock Deadlock
Exploit StatusProof-of-Concept (Regression PoC in Official Repository)
Affected Versionsnode-tar (npm: tar) < 8.0.2
Patched Version8.0.2

MITRE ATT&CK Mapping

T1499Endpoint Denial of Service
Impact
CWE-407
Inefficient Algorithmic Complexity

An algorithm in a product has an inefficient worst-case computational complexity that is detrimental to system performance and can be triggered by an attacker using crafted input.

Known Exploits & Detection

GitHubOfficial regression tests demonstrating deep linkpath and file filtering exhaustion vectors.
GitHubOfficial regression tests demonstrating 16-entry quadratic prefix allocation OOM crash in PathReservations.

Vulnerability Timeline

Initial commit (73b352e0010d6c99794ea7374800816a46d3bdb2) authored to enforce maxDepth on linkpath and MAX_PATH_LENGTH limits.
2026-11-27
Second fix commit (de87900752566867b422de0ebfe6592b30fa9786) authored to refactor PathReservations into a Trie and bound the Unicode normalization cache.
2026-11-28
Patched version node-tar v8.0.2 released to npm and GitHub.
2026-11-28
GitHub Security Advisory GHSA-7c32-79xj-j3jp and CVE-2026-140240 officially published.
2026-12-01

References & Sources

  • [1]CVE.org Record: CVE-2026-140240
  • [2]National Vulnerability Database (NVD): CVE-2026-140240
  • [3]GitHub Security Advisory: GHSA-7c32-79xj-j3jp
  • [4]node-tar v8.0.2 Release Notes
  • [5]Fix Commit: limit the work that a small archive can cause
  • [6]Fix Commit: limit the memory that long paths use in an async extraction
  • [7]CVE Project V5 Record JSON

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 3 hours ago•CVE-2026-140241
7.1

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

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.

Alon Barad
Alon Barad
5 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