Dec 2, 2026·11 min read·3 visits
An improper input validation flaw in node-tar versions 7.0.0 through 7.5.23 allows attackers to set an entry size to Infinity via crafted PAX extended headers. This causes archive extraction pipelines to drop subsequent file entries and triggers an uncaught exception that crashes the Node.js process during re-packing operations. Upgrade to version 7.5.24 to remediate the issue.
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.
The tar package (commonly referred to as node-tar) is a foundational archive manipulation library within the Node.js ecosystem. It provides streaming interfaces to pack, unpack, list, and modify TAR archives, supporting both standard UStar headers and POSIX.1-2001 Extended (PAX) headers. Package managers, build pipelines, container tooling, and web servers rely on node-tar to ingest and process archives originating from external or untrusted sources.
In node-tar versions >= 7.0.0 and < 7.5.24, the PAX extended header parser located in src/pax.ts contains an improper quantity validation vulnerability classified under CWE-1284 (Improper Validation of Specified Quantity in Input). When parsing key-value records inside a PAX header block, the library coerces the string representation of the size attribute into a JavaScript Number primitive using the unary plus operator (+v) and validates it solely by checking if the result is greater than or equal to zero (s >= 0).
Because JavaScript implements IEEE 754 double-precision floating-point arithmetic, coercing the literal string "Infinity" or an overflowing scientific notation string such as "1e400" yields the positive infinity constant (Number.POSITIVE_INFINITY). In IEEE 754 comparisons, Infinity >= 0 evaluates to true. Consequently, the parser accepts Infinity as a valid byte length and assigns it directly to the entry's size property.
This state corruption exposes downstream consumers to two primary failure modes depending on the operation performed. During extraction or listing operations, the stream state machine never reaches the end of the infinite entry, causing all subsequent archive headers and file payloads in the stream to be absorbed into the initial entry and omitted from extraction. During re-packing or serialization operations, arithmetic operations and buffer allocations operating on size: Infinity throw unhandled RangeError exceptions, terminating the Node.js process and causing a Denial of Service (DoS).
The POSIX.1-2001 (PAX) archive specification extends the legacy 512-byte UStar binary header format to overcome structural limitations, such as the 8 GiB file size ceiling and 100-character filename limits. A PAX extended header appears in the archive stream as a special entry with typeflag x (affecting the immediately following file entry) or g (setting global defaults for subsequent entries). The payload of a PAX block consists of newline-delimited key-value records formatted as <length> <key>=<value>\n, where <length> is the total decimal byte count of the record including the length field itself, the space delimiter, and the trailing newline.
When node-tar encounters a PAX extended header, it invokes Pax.parse(), which splits the payload into individual records and passes each key-value pair to the internal helper function parseKVLine in src/pax.ts. This function contains a switch statement that processes recognized PAX keywords (atime, mtime, ctime, gid, uid, size, and others) and populates a metadata dictionary object (set) that overrides the corresponding fields in the subsequent entry's standard UStar header.
The root cause of CVE-2026-140242 resides in the case 'size': branch of parseKVLine, introduced in version 7.0.0 via commit b0fbdea4631f9f65f15786fb5333695a9164a536. The vulnerable implementation relies on implicit type conversion without verifying the lexical syntax or numerical bounds of the input string:
+v) accepts any format recognized by the ECMAScript StringNumericLiteral grammar. Beyond base-10 integers, this includes the literal string "Infinity", scientific notation ("1e400"), fractional floats ("1.5"), hexadecimal literals ("0x10"), and strings containing leading or trailing whitespace.if (s >= 0) only rejects negative values and NaN (since NaN >= 0 is false). It fails to reject Infinity, floating-point decimals, or integers exceeding Number.MAX_SAFE_INTEGER ($2^{53} - 1 = 9,007,199,254,740,991$).Once set['size'] = Infinity is applied to an archive entry, the internal stream accounting inside node-tar's Unpack and Parser classes breaks down. The parser tracks remaining bytes for the active entry by decrementing entry.remain (initialized from entry.size) as data chunks flow through the stream. In IEEE 754 arithmetic, Infinity - chunk.length evaluates to Infinity. Because the remaining byte counter never reaches zero, the parser remains permanently locked in the file data consumption state. Every subsequent 512-byte UStar header block and file data block in the archive is piped directly into the first file's output stream rather than being parsed as distinct entries.
The vulnerability was resolved in node-tar version 7.5.24 via commit 6b815b7c10be504a01af2369a270add7099542d8. The patch modifies src/pax.ts to enforce both strict lexical validation and safe integer range checks before accepting a PAX size attribute.
src/pax.ts prior to 7.5.24)// src/pax.ts (lines 193-199)
set[k] = new Date(Number(v) * 1000)
break
case 'size':
const s = +v
if (s >= 0) set[k] = s
break
case 'gid':
case 'uid':In the unpatched code above, if v is "Infinity", const s = +v evaluates to Number.POSITIVE_INFINITY. The check if (s >= 0) passes, and set['size'] is set to Infinity. Similarly, if v is "1.5", set['size'] becomes 1.5, which introduces fractional byte misalignment in 512-byte block boundary calculations.
src/pax.ts in 7.5.24)// src/pax.ts
import { basename } from 'node:path'
import type { HeaderData } from './header.js'
import { Header } from './header.js'
// Added regex matching strictly canonical non-negative base-10 integers
const SIMPLE_NUMBER = /^(?:0|[1-9]\d*)$/
export class Pax implements HeaderData {
// ...
case 'size':
// value must be a string of digits with no negative sign
if (!SIMPLE_NUMBER.test(v.trim())) break
const s = +v
// must be a finite, non-negative integer, like the binary header path
if (!Number.isSafeInteger(s)) break
set[k] = s
breakThe remediation introduces a two-tier defense-in-depth validation mechanism that aligns the PAX parser with the binary UStar header parser:
SIMPLE_NUMBER): By testing v.trim() against /^(?:0|[1-9]\d*)$/, the parser restricts the input to either a single '0' or a non-zero digit followed by zero or more base-10 digits. This immediately rejects "Infinity", "NaN", negative signs, decimal points ("1.5"), scientific notation ("1e400"), hexadecimal prefixes, and zero-padded octal-like strings.Number.isSafeInteger): A numeric string consisting of 400 '9' characters ('9'.repeat(400)) passes the SIMPLE_NUMBER regular expression, but still coerces to Infinity when evaluated with +v. Even smaller digit strings exceeding 16 digits (such as '9007199254740993', which is $2^{53} + 1$) lose unit precision in IEEE 754 double-precision representation. Enforcing Number.isSafeInteger(s) guarantees that s is finite, an exact integer, and less than or equal to $2^{53} - 1$ (9007199254740991).> [!NOTE]
> In the same switch block in src/pax.ts, gid and uid parsing paths should also be kept in mind during code audits; however, for size, the combination of /^(?:0|[1-9]\d*)$/ and Number.isSafeInteger() completely eliminates non-finite and unsafe integer injection via PAX records.
Exploiting CVE-2026-140242 requires no authentication or elevated privileges, only the ability to supply a crafted TAR archive to an application or service using an affected version of node-tar (>= 7.0.0, < 7.5.24). The attack surface includes package registries, automated CI/CD artifact handlers, container layer parsers, and web upload endpoints that unpack or re-bundle user-supplied .tar or .tgz archives.
To trigger the vulnerability, an attacker constructs a PAX extended header block containing a size key set to a non-finite string representation. As demonstrated in the upstream regression test added in commit 6b815b7c10be504a01af2369a270add7099542d8, the minimal payload record is:
17 size=InfinityThe byte length prefix 17 is calculated from the components of the line:
"17" (2 bytes)" " (1 byte)"size=Infinity" (13 bytes)"\n" (1 byte)Alternatively, an attacker can use an oversized digit string (408 size= followed by 400 '9' digits and a newline) or scientific notation (14 size=1e400\n). In a complete TAR archive, this record is placed inside a 512-byte padded data block preceded by a standard 512-byte UStar header block whose typeflag byte (offset 156) is set to 'x' (0x78).
The following Node.js script demonstrates how the unpatched Pax.parse method evaluates the crafted records and corrupts the resulting header data structure:
import { Pax } from 'tar/dist/esm/pax.js'
// Construct the 17-byte PAX record
const payload = '17 size=Infinity\n'
const parsed = Pax.parse(payload)
console.log('Parsed size:', parsed.size)
// Vulnerable output (< 7.5.24): Parsed size: Infinity
// Patched output (>= 7.5.24): Parsed size: undefined17 size=Infinity\n, node-tar opens the write stream for entry #1 and reads until EOF. Entries #2 through #N are never extracted as separate files on disk; instead, their raw TAR header blocks and file contents are appended directly to the end of entry #1. If subsequent entries contain security policy files, configuration manifests, or validation signatures expected by the extraction pipeline, those files will be missing from the target directory.Pack stream (or creating a new Header instance from the parsed ReadEntry), the size: Infinity property propagates into the encoder. When the encoder attempts to encode the UStar/PAX header or compute 512-byte block padding (Math.ceil(size / 512) or buffer allocation), Node.js throws an unhandled runtime exception, terminating the worker or server process.CVE-2026-140242 carries a CVSS v4.0 base score of 7.1 (High) with the vector string CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:P/VC:N/VI:L/VA:H/SC:N/SI:N/SA:N. The scoring reflects a network-accessible attack vector (AV:N) with low attack complexity (AC:L), no special deployment requirements (AT:N), and no required privileges (PR:N), gated only by passive user or system interaction (UI:P) where a target process ingests an untrusted TAR archive.
VA:H)The primary severity driver is the high impact on system availability. Because Node.js operates on a single-threaded event loop by default, an uncaught synchronous exception thrown during buffer allocation or stream processing immediately terminates the active Node.js runtime process unless guarded by global process crash handlers or worker thread isolation. In multi-tenant backend services that parse and re-pack user archives (such as serverless deployment builders or package proxy caches), a single crafted archive request can crash the service daemon.
VI:L)The integrity impact is rated Low (VI:L). While the vulnerability does not allow an attacker to traverse directories or overwrite arbitrary files outside the extraction root, it allows the attacker to corrupt the structure of the extracted output. By forcing the first entry to consume the remainder of the archive stream, the first extracted file is polluted with raw binary TAR blocks, and all subsequent files in the archive are silently dropped without emitting a stream error.
VC:N, SC:N/SI:N/SA:N)There is no direct confidentiality impact (VC:N), as the flaw does not read out-of-bounds memory or exfiltrate host filesystem contents. Furthermore, the impact is contained to the vulnerable application processing the archive, resulting in no subsequent system impact (SC:N/SI:N/SA:N). According to CISA's Stakeholder-Specific Vulnerability Categorization (SSVC), exploitation maturity is at the Proof-of-Concept (poc) stage, the flaw is not considered automatable (no), and technical impact is partial.
The definitive remediation for CVE-2026-140242 is to upgrade node-tar (tar) to version 7.5.24 or later. Version 7.5.24 was published to the npm registry on November 26, 2026, and incorporates commit 6b815b7c10be504a01af2369a270add7099542d8, which drops invalid, non-finite, or unsafe integer size fields from PAX headers and falls back to the standard binary header size.
For projects with a direct dependency on tar, update the package via npm:
npm install tar@^7.5.24Because tar is frequently pulled in as a transitive dependency by build tools, CLIs, and framework SDKs, engineering teams should audit their complete dependency tree and refresh lockfiles:
# Inspect all installed versions of tar in the dependency tree
npm ls tar
# Apply automated security updates to lockfiles
npm audit fixIf a third-party parent package pins a vulnerable version range within the 7.x release line (e.g., ~7.4.0), use the overrides field in package.json (or resolutions in Yarn / pnpm.overrides in pnpm) to force resolution to 7.5.24:
{
"overrides": {
"tar": "^7.5.24"
}
}In environments where immediate dependency patching is blocked, teams can apply defense-in-depth measures around archive ingestion pipelines:
onReadEntry / filter Hooks: When using tar.x() or tar.t(), attach an entry inspection callback that verifies Number.isSafeInteger(entry.size) before permitting extraction or downstream re-packing. If entry.size is !Number.isSafeInteger(entry.size) or exceeds expected operational limits (for example, 1 GiB), immediately destroy the stream (entry.destroy() or stream.destroy(new Error('Invalid entry size'))).node:child_process) or Worker Threads (node:worker_threads) with strict memory and execution timeouts so that an uncaught exception does not terminate the main application server.CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:P/VC:N/VI:L/VA:H/SC:N/SI:N/SA:N| Product | Affected Versions | Fixed Version |
|---|---|---|
tar (node-tar) isaacs | >= 7.0.0, < 7.5.24 | 7.5.24 |
| Attribute | Detail |
|---|---|
| CVE / GHSA ID | CVE-2026-140242 / GHSA-ph3c-p786-j4rp |
| Weakness Class | CWE-1284 (Improper Validation of Specified Quantity in Input) |
| CVSS v4.0 Score | 7.1 High (CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:P/VC:N/VI:L/VA:H/SC:N/SI:N/SA:N) |
| Affected Package | tar (node-tar) >= 7.0.0, < 7.5.24 |
| Patched Version | 7.5.24 |
| Primary Impact | Archive Entry Loss (Integrity) & Process Termination via Uncaught Exception (Availability) |
| Exploit Status | Proof-of-Concept (PoC in upstream test suite) |
| CISA KEV Status | Not Listed |
The software receives an input that specifies a quantity (such as size or count), but it does not validate or incorrectly validates that the quantity conforms to required operational limits.
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.
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.
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.
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.
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.
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.