Dec 2, 2026·12 min read·3 visits
An archive framing differential in node-tar prior to version 8.0.0 allows attackers to smuggle hidden archive members past upstream security filters or inject arbitrary members during archive repacking by exploiting improper application of PAX extended headers to meta entries.
node-tar prior to version 8.0.0 contains an interpretation conflict (CWE-436) in its ReadEntry and PAX header parsing implementations. The ReadEntry class improperly applies PAX size attributes to GNU and PAX metadata entries, reverses local-versus-global PAX precedence, and splits PAX records by newline characters rather than explicit byte length fields. These parsing inconsistencies cause node-tar to frame archive boundaries differently from standard tar implementations, enabling security scanner bypasses, maxMetaEntrySize memory cap evasion, and member injection during archive repacking operations.
node-tar (published as tar on the npm registry) is the foundational tar archive manipulation library for the Node.js ecosystem. It provides stream-based extraction, creation, listing, and archive repacking capabilities used by package managers, build pipelines, and command-line utilities. Because it frequently processes untrusted archives fetched over the network, its header parsing and block boundary framing logic represent a critical security boundary.
CVE-2026-140236 (also tracked as GHSA-qv2w-fc3h-pm27) is an interpretation conflict (CWE-436) affecting all versions of node-tar prior to 8.0.0. The vulnerability stems from how the ReadEntry class and the PAX parsing subsystem (src/pax.ts) handle POSIX.1-2001 (PAX) extended headers and GNU meta entries (././@LongLink). While an earlier patch in version 7.5.16 prevented Header.decode from applying PAX attributes to non-file blocks, ReadEntry continued to consume and apply pending PAX properties across all entries without checking whether the target entry was a metadata block.
When a crafted archive places a PAX extended header defining a size attribute immediately before a GNU or PAX metadata entry, ReadEntry overwrites the metadata entry's size property while leaving internal block remainder counters anchored to the raw 512-byte header size. Additionally, ReadEntry processes global PAX headers after local PAX headers, inverting standard POSIX precedence rules. The PAX key-value parser also splits records on raw newline characters (\n) rather than framing records by their declared decimal byte lengths.
These combined flaws create an archive framing differential between node-tar and compliant implementations such as GNU tar, bsdtar, and Python's tarfile. An attacker can construct a polyglot or desynchronized tar archive where security inspection tools observe one set of benign files, while node-tar extracts or repacks concealed archive members. Furthermore, applications utilizing node-tar's archive repacking surface (@archive input syntax or Pack.add(ReadEntry)) are vulnerable to arbitrary archive member injection due to mismatches between declared header sizes and copied body bytes.
The root cause of CVE-2026-140236 comprises four distinct state-handling and parsing defects across src/read-entry.ts, src/pax.ts, src/parse.ts, and src/header.ts. In the tar format, extended headers (type x for local PAX headers, g for global PAX headers) and GNU long path entries (type L for NextFileHasLongPath, K for NextFileHasLongLinkpath) are metadata blocks. Their body content describes attributes for the next regular file entry in the stream, not for intermediate metadata blocks.
First, during the instantiation of a ReadEntry object in src/read-entry.ts, the constructor receives the decoded Header object alongside any currently active local (ex) and global (gex) PAX header objects. In versions prior to 8.0.0, ReadEntry unconditionally invoked its private #slurp method to copy properties from ex and gex onto this, omitting a guard for !this.meta. Furthermore, #slurp failed to exclude the size, global, and global linkpath properties. Because the Header class had already computed this.remain and this.blockRemain using the base header's octally encoded size, overwriting this.size inside ReadEntry desynchronized the entry's advertised size from its actual stream consumption length.
Second, ReadEntry applied local PAX headers before global PAX headers by calling this.#slurp(ex) followed immediately by this.#slurp(gex, true). Because #slurp uses Object.assign to merge properties onto the ReadEntry instance, any property defined in an active global extended header overwrote the corresponding property set by a file-specific local extended header. This directly violates the POSIX.1-2001 specification, which mandates that local extended headers override global defaults.
Third, the PAX payload parser (parseKV in src/pax.ts) parsed key-value records by stripping trailing newlines and calling .split('\n'). The POSIX specification defines PAX records using the format <length> <key>=<value>\n, where <length> is the total byte length of the record in ASCII decimal, including the length prefix, space, key, equals sign, value, and trailing newline. Because values can legitimately contain embedded newline characters, splitting on \n allowed a multiline PAX attribute value to inject forged PAX key-value lines into the parser.
Fourth, inconsistent precedence and validation rules existed across src/parse.ts, src/pax.ts, and src/header.ts. When a PAX extended header and a GNU @LongLink metadata block were combined for the same entry, GNU long path assignments unconditionally overwrote PAX path and linkpath attributes instead of yielding precedence to PAX. Additionally, ReadEntry evaluated the maxMetaEntrySize security limit against the slurped, spoofable entry.size property rather than the physical header.size value, allowing attackers to bypass memory allocation limits on metadata buffers.
The remediation in commit f351e5b4a8916bc8c8f821d0ad926a17d26ea237 modifies src/read-entry.ts, src/pax.ts, src/parse.ts, and src/header.ts to enforce strict POSIX compliance and eliminate framing differentials.
In src/read-entry.ts, the constructor and the #slurp helper method were updated to isolate metadata entries from extended header inheritance, invert the execution order of gex and ex so local attributes prevail, and block #slurp from mutating size, global, or global linkpath attributes:
// src/read-entry.ts
export class ReadEntry extends Minipass<Buffer, Buffer> {
constructor(header: Header, ex?: Pax, gex?: Pax) {
// ... [header property initialization] ...
this.uname = header.uname
this.gname = header.gname
// FIX 1: Only apply extended headers to non-meta file entries.
// FIX 2: Apply global extended headers (gex) before local (ex)
// so that local values overwrite global values.
if (!this.meta) {
if (gex) {
this.#slurp(gex, true)
}
if (ex) {
this.#slurp(ex)
}
}
}
#slurp(ex: Pax, gex = false) {
Object.assign(
this,
Object.fromEntries(
Object.entries(ex).filter(([k, v]) => {
// FIX 3: Never overwrite 'size' (already resolved by Header),
// 'global', or 'linkpath' from a global extended header.
return !(
v === null ||
v === undefined ||
k === 'size' ||
k === 'global' ||
(k === 'path' && gex) ||
(k === 'linkpath' && gex)
)
}),
),
)
}
}In src/pax.ts, the naive newline-splitting parseKV function was replaced with a byte-length scanner. The updated parser reads the ASCII decimal length prefix (0x30 through 0x39) up to the space delimiter (0x20), calculates the exact end offset (pos + n), verifies that the byte at end - 1 is a line feed (0x0a), and slices the UTF-8 key-value pair directly from the buffer. If any record violates length framing, parsing terminates immediately:
// src/pax.ts
const parseKV = (str: string) => {
const set: Record<string, string | number | Date> = Object.create(null)
const buf = Buffer.from(str)
let pos = 0
while (pos < buf.length) {
let sp = pos
// Scan ASCII digits for the byte length prefix
while (
sp < buf.length &&
(buf[sp] as number) >= 0x30 &&
(buf[sp] as number) <= 0x39
) {
sp++
}
// Require at least one digit followed by a space (0x20)
if (sp === pos || buf[sp] !== 0x20) break
const n = Number(buf.toString('ascii', pos, sp))
const end = pos + n
// Validate record bounds and trailing newline (0x0a)
if (end <= sp + 1 || end > buf.length || buf[end - 1] !== 0x0a) break
parseKVLine(set, buf.toString('utf8', sp + 1, end - 1))
pos = end
}
return set
}Also in src/pax.ts, numeric field parsing was hardened. The regular expression SIMPLE_NUMBER was relaxed from /^(?:0|[1-9]\d*)$/ to /^\d+$/ to permit leading zeros in decimal strings per the POSIX standard, while parseKVLine added a Number.isSafeInteger(s) check to reject out-of-bounds integers that evaluate to Infinity:
// src/pax.ts
const SIMPLE_NUMBER = /^\d+$/
// Inside parseKVLine:
const s = Number(val)
if (!Number.isSafeInteger(s)) {
return set
}In src/parse.ts, the meta entry buffer handling was updated in three ways. First, the maxMetaEntrySize check now evaluates entry.header.size instead of entry.size, preventing PAX size overrides from bypassing memory limits. Second, when a GNU NextFileHasLongPath or NextFileHasLongLinkpath entry finishes buffering, it uses the nullish coalescing assignment operator (??=) when writing to this.#ex.path or this.#ex.linkpath, ensuring that explicit PAX path declarations take precedence over GNU @LongLink blocks. Third, in src/header.ts, the null-byte truncation regular expression was changed from /\0.*/ to /\0.*/s (enabling the dotAll flag) so that NUL bytes followed by newline characters inside fixed-length header strings are completely stripped.
> [!NOTE]
> The fix in commit f351e5b4a8916bc8c8f821d0ad926a17d26ea237 is comprehensive with respect to PAX and GNU metadata framing. By moving all size resolution exclusively into Header.decode and prohibiting ReadEntry from mutating size or applying attributes to .meta entries, the state desynchronization vector between header framing and stream consumption is closed.
Exploitation of CVE-2026-140236 does not require authentication or special system privileges; it requires an application or build pipeline to process a crafted tar archive using node-tar prior to version 8.0.0. Two primary exploitation methodologies exist: archive smuggling across security inspection boundaries, and arbitrary member injection during archive repacking.
In the archive smuggling scenario, an attacker targets a pipeline where an archive is first inspected by a standard tar parser (such as bsdtar, GNU tar, or a Python tarfile-based antivirus/linter) before being unpacked or processed by node-tar (or vice versa). The attacker constructs a tar stream containing a PAX extended header with size=0, followed by a 512-byte GNU ././@LongLink metadata block whose payload is itself formatted as a valid 512-byte USTAR header for a malicious file:
// Upstream regression PoC (test/parse-differential.test.ts)
// Demonstrates framing differential when PAX size=0 precedes a GNU LongLink
await paths([
pax([['size', '0']]),
hdr({
path: '././@LongLink',
type: 'NextFileHasLongPath',
size: 512,
}),
hdr({ path: 'payload-only.txt', type: 'File' }),
file('real.txt'),
])When a compliant tar implementation reads this stream, it ignores the PAX size=0 for the ././@LongLink metadata block, consumes the next 512 bytes as the long filename string, and treats the subsequent block as the target file header. In contrast, vulnerable versions of node-tar apply size=0 to the ReadEntry representing ././@LongLink or misalign the entry framing during filter callbacks. Similarly, by embedding a newline character inside a PAX attribute value (e.g., comment=benign\n11 size=512), an attacker can inject a synthetic size=512 key-value pair that is ignored by length-framed POSIX parsers but honored by node-tar's newline-splitting parseKV parser.
In the archive repacking scenario, the attacker exploits applications that repackage existing archives using node-tar's @archive.tar syntax in tar.create() / tar.replace(), or that pipe ReadEntry instances directly into Pack.add(readEntry). When repacking, WriteEntryTar writes an output header based on readEntry.size (or mutated PAX headers), while streaming the raw body bytes dictated by readEntry.blockRemain:
// Upstream regression PoC (test/parse-differential.test.ts)
// Demonstrates filter bypass during @archive repacking
fs.writeFileSync(
input,
Buffer.concat([
pax([['size', '512']]),
pax([['size', '0']], true), // Global PAX header with size=0
hdr({ path: 'carrier.txt', type: 'File', size: 512 }),
hdr({ path: 'hidden.txt', type: 'File' }),
EOA,
]),
)
await create(
{
file: output,
filter: p => {
seen.push(p)
return p !== 'hidden.txt'
},
},
['@' + input],
)In vulnerable versions, the global PAX header (size=0) overrides the local PAX header (size=512) inside ReadEntry due to the inverted #slurp precedence. The filter callback inspects carrier.txt (seeing size=0), while the underlying stream copies the 512-byte body block containing the raw header for hidden.txt directly into the output archive. When the resulting out.tar archive is later extracted, hidden.txt emerges as a top-level archive member despite having been explicitly rejected by the filter function.
CVE-2026-140236 is rated High severity with a CVSS v4.0 base score of 7.2 (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 vector reflects a network-accessible attack surface (AV:N) with low attack complexity (AC:L), no special attack requirements (AT:N), no required privileges (PR:N), and passive user or pipeline interaction (UI:P).
The primary security impact is a high loss of integrity (VI:H) on the vulnerable system. By exploiting the interpretation conflict between node-tar and upstream validation tools, an attacker can bypass file path filters, extension allowlists, and content inspection scanners. During archive repacking operations, attackers can smuggle unauthorized files into newly generated archives, bypassing custom filter predicates supplied to tar.create().
A secondary impact involves low availability degradation (VA:L) and low confidentiality exposure (VC:L). Because src/parse.ts previously validated entry.size > this.maxMetaEntrySize after ReadEntry had already overwritten entry.size with the PAX size attribute, an attacker could declare a PAX header with size=0 ahead of a multi-megabyte GNU @LongLink block. This allowed the metadata entry to bypass the maxMetaEntrySize limit and buffer unbounded data into memory, leading to heap exhaustion and Denial of Service (DoS) within the Node.js process.
To remediate CVE-2026-140236, upgrade node-tar (tar) to version 8.0.0 or later. Version 8.0.0 contains commit f351e5b4a8916bc8c8f821d0ad926a17d26ea237, which resolves all PAX size inheritance, precedence, and record framing inconsistencies.
npm install tar@^8.0.0If tar is installed as a transitive dependency within a project tree, enforce resolution to version 8.0.0 or higher using the overrides field in package.json (supported in npm 8.3.0 and later):
{
"overrides": {
"tar": "^8.0.0"
}
}> [!NOTE]
> Upgrading to node-tar version 8.0.0 introduces breaking architectural changes. Version 8.0.0 requires Node.js >= 22, replaces legacy Minipass streams with standard Web Streams (ReadableStream), and removes callback-based invocation signatures in favor of native Promises and async generators.
For environments locked to Node.js versions prior to v22 where an immediate upgrade to tar@8.0.0 is not feasible, apply the following mitigations:
@archive.tar arguments to tar.create() or tar.replace(), and do not pass ReadEntry objects into Pack.add().node-tar's filter option during repacking or listing to enforce security boundaries against untrusted archives.bsdtar or GNU tar) to extract and re-create a clean USTAR archive before passing it to node-tar.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| Product | Affected Versions | Fixed Version |
|---|---|---|
node-tar (tar) isaacs | < 8.0.0 | 8.0.0 |
| Attribute | Detail |
|---|---|
| Vulnerability ID | CVE-2026-140236 / GHSA-qv2w-fc3h-pm27 |
| Weakness Type | CWE-436 (Interpretation Conflict) |
| CVSS v4.0 Score | 7.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) |
| Affected Package | node-tar (tar on npm) < 8.0.0 |
| Patched Version | 8.0.0 |
| Primary Impact | Archive Framing Differential, Filter Bypass, and Repack Member Injection |
| Exploit Status | PoC Available (Upstream Regression Tests) |
| CISA KEV Status | Not Listed |
Product A handles inputs or steps differently than Product B, which causes A to perform incorrect actions based on its perception of B's state.
A parsing vulnerability in the node-tar archive manipulation library for Node.js (versions 7.5.0 through 7.5.24) allows attackers to drop legitimate metadata fields and inject forged entry attributes into tar archives. By splitting POSIX.1-2001 PAX extended headers on newline characters rather than respecting explicit byte-length framing, the parser misinterprets embedded newlines inside attribute values as record delimiters. This enables arbitrary file overwrite within the extraction directory, metadata tampering, archive desynchronization, and arbitrary path traversal when non-default path preservation settings are enabled.
CVE-2026-140234 (GHSA-wpwg-r92p-fjjh) is an improper null byte neutralization vulnerability (CWE-158) in node-tar versions prior to 8.0.0. The regular expression used to truncate null-terminated header strings omits the dotAll (s) flag, causing truncation to halt prematurely when a null byte is followed by a line terminator. This defect allows embedded null bytes and trailing characters to persist in parsed file and link paths, resulting in asynchronous Node.js process crashes via native filesystem validation errors and path differentials against compliant TAR implementations.
CVE-2026-140248 is a High-severity path traversal and symbolic link resolution vulnerability (CWE-59) in the npm package tar (node-tar) affecting versions 7.5.22 through 7.5.24. When extracting archives under default security configurations (preservePaths: false), node-tar validates symbolic link targets using purely lexical path normalization via path.posix functions without accounting for intermediate symbolic link resolution on the host filesystem. By crafting an archive containing chained symbolic links, paths ending in trailing '/.' segments, or POSIX directory names containing backslashes, an attacker can plant a symbolic link inside the extraction directory that resolves to arbitrary locations outside the destination root. Downstream processes reading or writing through the extracted symlink can consequently disclose or overwrite arbitrary files on the host system.
A CRLF injection and HTTP request splitting vulnerability exists in the Ruby addressable gem from version 2.1.2 prior to 2.10.0. The Addressable::URI#request_uri method returns stored control characters and spaces without percent-encoding them. When an HTTP client writes the output of #request_uri directly into an HTTP request line without additional validation or normalization, an attacker supplying an untrusted URI can terminate the request line prematurely, inject arbitrary HTTP headers, or initiate a secondary HTTP request over a keep-alive connection.
CVE-2026-141530 is a user interface misrepresentation vulnerability in the pure-Ruby Internationalized Domain Names in Applications (IDNA) implementation of the Addressable gem (versions 2.0.0 through 2.9.2). The library omits enforcement of the RFC 3454 Section 6 bidirectional rule when converting between Punycode A-labels and Unicode U-labels. Consequently, calling Addressable::IDNA.to_unicode or Addressable::URI#display_uri decodes malformed Punycode labels containing mixed directional categories and trailing digits. When rendered in a standard left-to-right display context, the Unicode Bidirectional Algorithm visually reorders digits across domain label separators, enabling an attacker controlling a complementary domain to spoof a target hostname.
An authentication bypass vulnerability in the Symfony Security HTTP component (symfony/security-http) causes programmatic login operations to skip the checkPostAuth() method of configured user checkers. Because AuthenticatorManager::authenticateUser() fails to dispatch the security.authentication.success event, custom post-authentication restrictions—such as checks for expired or locked accounts—are bypassed when users authenticate via programmatic flows like password resets or email verification callbacks.