Dev.to Security 🔐 Cybersecurity 👁 2 📖 4 min read

CVE-2026-140230: CVE-2026-140230: Quadratic Memory Amplification Denial of Service in node-tar PathReservations

CVE-2026-140230: Quadratic Memory Amplification Denial of Service in node-tar PathReservations Vulnerability ID: CVE-2026-140230 CVSS Score: 7.5 Published: 2026-12-02 CVE-2026-140230 (GHSA-xm6h-2993-3ch9) is an unco

CVE-2026-140230: Quadratic Memory Amplification Denial of Service in node-tar PathReservations

Vulnerability ID: CVE-2026-140230
CVSS Score: 7.5
Published: 2026-12-02

CVE-2026-140230 (GHSA-xm6h-2993-3ch9) is an uncontrolled resource consumption vulnerability in the node-tar npm package (tar) prior to version 8.0.0. The flaw stems from asymmetric path depth validation during archive extraction: while entry.path is validated against a maximum segment depth (maxDepth = 1024), entry.linkpath is omitted from this check. When extracting a symbolic or hard link entry with a deeply nested linkpath defined via a GNU LongLink ('K') extended header, the PathReservations subsystem decomposes the path into every parent directory prefix, triggering quadratic O(N^2) string materialization in the V8 heap. A compressed archive as small as 181 bytes forces the Node.js runtime into an uncatchable fatal Out-Of-Memory (OOM) abort.

TL;DR

Versions of node-tar prior to 8.0.0 fail to enforce directory depth limits on entry.linkpath during archive extraction. Passing an archive containing a deeply nested symbolic link target via GNU LongLink extended headers triggers quadratic O(N^2) memory allocation in PathReservations.getDirs(), crashing the Node.js process via an uncatchable V8 heap exhaustion abort from a 181-byte payload.

⚠️ Exploit Status: POC

Technical Details

  • CVE / Advisory ID: CVE-2026-140230 / GHSA-xm6h-2993-3ch9
  • Vulnerability Class: CWE-400: Uncontrolled Resource Consumption (O(N^2) Memory Amplification)
  • Affected Component: node-tar (npm: tar) < 8.0.0 (src/unpack.ts & src/path-reservations.ts)
  • CVSS Score: 7.5 High (CVSS v3.1) / 7.1 High (CVSS v4.0)
  • Attack Vector: Network / Craft GNU LongLink ('K') Header with Deep entry.linkpath
  • Impact: Uncatchable V8 Fatal Out-Of-Memory (OOM) Process Abort via 181-Byte Payload
  • Exploit & KEV Status: Public PoC Available / Not Listed in CISA KEV (EPSS: 0.55%)
  • Patched Version: tar >= 8.0.0 (Commit 73b352e0010d6c99794ea7374800816a46d3bdb2)

Affected Systems

  • node-tar (npm package: tar) < 8.0.0
  • Node.js applications, build pipelines, and package utilities extracting untrusted tar archives via node-tar < 8.0.0
  • tar: < 8.0.0 (Fixed in: 8.0.0)

Code Analysis

Commit: 73b352e

limit the work that a small archive can cause: enforce maxDepth and MAX_PATH_LENGTH (32768) on entry.linkpath, deduplicate reservation paths, and delete completed path reservations.

diff --git a/src/unpack.ts b/src/unpack.ts
index 5166e1ec..8ef319df 100644
--- a/src/unpack.ts
+++ b/src/unpack.ts
@@ -53,6 +53,8 @@ const CHECKED_CWD = Symbol('checkedCwd')
 const platform = process.env.TESTING_TAR_FAKE_PLATFORM || process.platform
 const isWindows = platform === 'win32'
 const DEFAULT_MAX_DEPTH = 1024
+// Longer than any path that a supported platform can create.
+const MAX_PATH_LENGTH = 32768

 // Unlinks on Windows are not atomic.
 //
@@ -361,6 +363,35 @@ export class Unpack extends Parser {
       return false
     }

+    // The path reservation system does work for each parent
+    // directory of the path and of the linkpath.
+    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
+    }
+    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
+      }
+    }
+
     if (
       !this[STRIPABSOLUTEPATH](entry, 'path') ||
       !this[STRIPABSOLUTEPATH](entry, 'linkpath')

Exploit Details

Mitigation Strategies

  • Upgrade the npm 'tar' package to version 8.0.0 or later to enforce symmetric maxDepth and MAX_PATH_LENGTH (32,768 characters) validation across both entry.path and entry.linkpath.
  • Implement a pre-extraction filter callback in tar.x() / tar.extract() for legacy v6.x and v7.x deployments to reject any ReadEntry where entry.linkpath exceeds 1,024 path segments or 32,768 characters before PathReservations.reserve() is invoked.
  • Isolate untrusted archive extraction workloads inside dedicated worker processes or sandboxed containers with strict memory quotas and automatic process supervision so an OOM crash does not terminate the primary application server.
  • Inspect uncompressed archive headers at ingestion gateways for GNU LongLink (typeflag 'K') and PAX extended header records containing more than 1,024 forward-slash ('/') delimiters.

Remediation Steps:

  1. Run 'npm ls tar' across all Node.js repositories to identify direct and transitive installations of tar < 8.0.0.
  2. Update package.json manifests to require 'tar': '^8.0.0' and regenerate lockfiles via 'npm install'.
  3. If transitive dependencies pin tar to 6.x or 7.x and cannot be upgraded to v8.0.0 due to breaking API changes, inject an extraction 'filter' callback that bounds entry.linkpath segment count and byte length.
  4. Verify remediation using the Nuclei manifest detection template or by testing extraction against a 10,000-segment GNU 'K' header test archive and confirming that 'TAR_ENTRY_ERROR: linkpath excessively deep' is emitted without heap growth.

References

Read the full report for CVE-2026-140230 on our website for more details including interactive diagrams and full exploit analysis.

📰 Read the original article on Dev.to Security

Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.