Dec 2, 2026·14 min read·1 visit
A lexical path validation flaw in node-tar versions 7.5.22 to 7.5.24 allows crafted tar archives to bypass symlink extraction restrictions and create symbolic links pointing outside the target extraction directory.
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.
The tar package (commonly known as node-tar) is the foundational tar archive creation and extraction library for the Node.js ecosystem. It is widely deployed across package managers, continuous integration and deployment (CI/CD) pipelines, cloud functions, and application servers to process compressed and uncompressed archives. Because archives frequently originate from untrusted external users or public registries, node-tar implements a default security sandbox (preservePaths: false) designed to confine all extracted files, directories, and links strictly within the designated extraction working directory (cwd).
CVE-2026-140248 (also tracked as GitHub Security Advisory GHSA-6wwr-g865-f46r) is an Improper Link Resolution Before File Access vulnerability (CWE-59) within node-tar's path validation routine in src/unpack.ts. Introduced in version 7.5.22 via commit 2a22bfc5d3a432a606d9da0e2d87ba634aa3b1cb, the flaw lies in how the [STRIPABSOLUTEPATH] method validates the linkpath target of SymbolicLink archive entries. The validator uses purely lexical string manipulation via Node's path.posix module to calculate whether a relative symlink target escapes the extraction root.
Lexical path normalization operates under the assumption that every named segment in a file path is a physical directory. It cancels out any <name>/.. sequence syntactically before checking whether the resulting path begins with ../. However, when an operating system kernel resolves a path on a real filesystem, it resolves intermediate symbolic links first before evaluating subsequent parent directory (..) segments.
By supplying a malicious archive that combines an in-root symbolic link with a second symbolic link traversing through that first link and appending .. sequences, an attacker creates a discrepancy between the lexical path evaluated by node-tar and the actual physical path resolved by the operating system. Additional bypass vectors involving trailing /. segments in entry paths and backslashes inside POSIX directory names also cause the lexical depth calculation to fail. As a result, node-tar permits the extraction of symbolic links that point outside the target directory, enabling arbitrary file overwrite or disclosure when downstream consumers interact with the extracted files.
When node-tar extracts an archive with preservePaths: false, it invokes the [STRIPABSOLUTEPATH] method in src/unpack.ts on both the entry's destination path (entry.path) and, for symbolic links, the link's target (entry.linkpath). Prior to version 8.0.0, the validation logic calculated the entry's parent directory using const entryDir = path.posix.dirname(entry.path) and then normalized the joined path via path.posix.normalize(path.posix.join(entryDir, parts.join('/'))). If the resulting string did not equal '..' or start with '../', the validator considered the symbolic link safe to write to disk.
This lexical approach fails under three distinct conditions where syntactic path depth diverges from filesystem path depth:
The first and primary failure mode is nested symbolic link traversal, where .. components appear after a named path segment that is itself a symbolic link. Suppose an archive extracted into /app/target creates a directory a, a symlink a/b pointing to ../x (which resolves to /app/target/x, remaining safely inside the root), and a second symlink a/esc pointing to b/../../outside.txt. When validating a/esc, entryDir is 'a'. Joining 'a' and 'b/../../outside.txt' yields 'a/b/../../outside.txt'. The lexical normalizer collapses b/.. and then a/.., producing 'outside.txt'. Because 'outside.txt' does not begin with '../', node-tar creates the symlink. On the filesystem, accessing /app/target/a/esc causes the OS kernel to first follow a/b to /app/target/x. From /app/target/x, the first .. ascends to /app/target, and the second .. ascends to /app, escaping the extraction root.
The second failure mode involves unnormalized entry paths ending in /. or /./. If an archive contains a symlink entry with entry.path set to 'esc/.' and linkpath set to '../outside.txt', the filesystem creates the symbolic link at 'esc' in the root of the extraction directory (depth 0). However, calling path.posix.dirname('esc/.') without prior normalization returns 'esc' (depth 1) instead of '.' (depth 0). When the validator joins 'esc' with '../outside.txt', path.posix.normalize collapses the pair into 'outside.txt'. The validator approves the link, even though 'esc' resides at the extraction root and its target '../outside.txt' immediately points one level above the extraction directory.
The third failure mode occurs on POSIX filesystems when directory names contain backslash (\) characters. On POSIX platforms, a backslash is a valid filename character rather than a path separator, meaning an archive entry 'A\B' creates a single directory at depth 1. Because node-tar normalizes backslashes into forward slashes when splitting linkpath into parts, a symlink at the root pointing to 'A\B/../../outside.txt' has its target split into ['A', 'B', '..', '..', 'outside.txt']. Lexically, A and B appear to have depth 2, cancelling out both .. segments. On a POSIX filesystem or when traversed via a symlink targeting the literal directory 'A\B', the first .. ascends back to the extraction root and the second .. escapes to the parent directory.
The vulnerability was remediated in node-tar version 8.0.0 via commit 23b368128b6cf7d4c26f2e302c0e4a82f70a6e3d. The modification takes place in src/unpack.ts inside the [STRIPABSOLUTEPATH] method during the validation of SymbolicLink targets.
// 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('/')),
)
// If the resolved path escapes (starts with ..), reject it
if (resolved.startsWith('../') || resolved === '..') {
this.warn(
'TAR_ENTRY_ERROR',
`${field} escapes extraction directory`,
{ entry, [field]: p },
)
return false
}In the unpatched implementation, parts is an array of path segments derived from linkpath. The code assumes that joining entryDir and parts.join('/') and passing the result through path.posix.normalize accurately models how the target path will resolve on disk. It neither restricts where .. segments can appear within parts nor normalizes entry.path prior to calling path.posix.dirname.
diff --git a/src/unpack.ts b/src/unpack.ts
index e5a3fc5..5fc7cb5 100644
--- a/src/unpack.ts
+++ b/src/unpack.ts
@@ -279,7 +279,23 @@ export class Unpack extends Parser {
// 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)
+ // 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('/')),
)The patch introduces two distinct structural checks that address all three bypass vectors:
parts (any segment other than '..', '.', or '') and stores it in firstName. It then checks parts.includes('..', firstName). If any '..' segment appears after a named path segment, the entry is rejected with the warning ${field} contains '..' after a path portion. This guarantees that relative parent directory traversals can only occur at the immediate start of a linkpath (e.g., ../../target), traversing upward exclusively through the known directory hierarchy of entryDir before encountering any potentially redirected named component. This also neutralizes the POSIX backslash vector (A\B/../../outside.txt), because splitting on slashes produces ['A', 'B', '..', '..', 'outside.txt'], where '..' appears after the named segment 'A'.entry.path: By changing path.posix.dirname(entry.path) to path.posix.dirname(path.posix.normalize(entry.path)), any trailing /. or /./ sequences are stripped before calculating the containing directory. For entry.path = 'esc/.', path.posix.normalize('esc/.') returns 'esc', and path.posix.dirname('esc') returns '.'. Joining '.' with '../outside.txt' normalizes to '../outside.txt', which triggers the resolved.startsWith('../') rejection.> [!NOTE]
> The fix is complete with respect to lexical validation of relative linkpath targets. Because node-tar prevents extracted entries themselves from being placed inside previously extracted symbolic link directories through separate filesystem cache and lstat checks during extraction, restricting .. strictly to the leading prefix of linkpath ensures that all upward traversal happens from a verified physical directory depth within the extraction tree.
Exploiting CVE-2026-140248 requires an attacker to supply a crafted .tar archive to an application or service that extracts it using node-tar versions 7.5.22, 7.5.23, or 7.5.24 with default extraction settings (preservePaths: false). No special system privileges or race conditions (AT:N, AC:L) are needed; the archive structure is entirely deterministic.
It is important to distinguish between the creation of the escaping symlink during extraction and the subsequent exploitation of that symlink. During the archive extraction phase itself, node-tar's internal unpacker uses lstat and unlinks or refuses to traverse through existing symlinks when writing later archive entries. However, once extraction finishes, the malicious symlink remains planted inside the destination directory pointing to an external path on the host filesystem. Any subsequent application logic, build step, file reader, or post-extraction script that accesses files inside the extracted directory will follow the planted symlink outside the sandbox.
The following test suite excerpt from test/symlink-linkpath-escape.test.ts in commit 23b368128b6cf7d4c26f2e302c0e4a82f70a6e3d demonstrates seven distinct archive header sequences that bypass the vulnerable validator:
import { Header, type HeaderData } from '../src/header.js'
const link = (path: string, linkpath: string): HeaderData => ({
path,
linkpath,
type: 'SymbolicLink',
})
const dir = (path: string): HeaderData => ({ path, type: 'Directory' })
// Each tuple defines the archive entries that escape the extraction root
// on node-tar 7.5.22 - 7.5.24:
const escapes: Record<string, HeaderData[]> = {
// Vector 1a: Symlink to current dir followed by 's1/..'
"'..' after an earlier symlink": [
link('s1', '.'),
link('esc', 's1/../outside.txt'),
],
// Vector 1b: Symlink created AFTER the escaping symlink in archive order
"'..' after a later symlink": [
link('esc', 'x/y/../outside.txt'),
dir('x'),
link('x/y', '..'),
],
// Vector 1c: Nested directory symlink redirecting upward
"'..' after a nested symlink": [
dir('a'),
link('a/b', '../x'),
link('a/esc', 'b/../../outside.txt'),
],
// Vector 2a: Trailing '/.' inflating dirname depth
"entry path that ends in '/.'": [
link('esc/.', '../outside.txt'),
],
// Vector 2b: Trailing '/./' inflating dirname depth
"entry path that ends in '/./'": [
link('esc/./', '../outside.txt'),
],
// Vector 2c: Nested entry path with trailing '/.'
"nested entry path that ends in '/.'": [
dir('a'),
link('a/esc/.', '../../outside.txt'),
],
// Vector 3: Backslash in POSIX directory name
'backslash in a directory name': [
dir('A\\B'),
link('esc', 'A\\B/../../outside.txt'),
],
}As shown in Vector 1b ('..' after a later symlink), the order of entries in the tar archive does not restrict the attack. Because node-tar validates linkpath purely lexically at the moment each header is read, link('esc', 'x/y/../outside.txt') can appear as the very first entry in the archive before dir('x') and link('x/y', '..') even exist on disk.
Consider a web service or CI/CD runner that extracts user-supplied artifact archives into /tmp/builds/job-101/ and then executes a post-processing step that reads configuration files (e.g., fs.readFileSync('/tmp/builds/job-101/config.json')) or writes build output back into the workspace (e.g., fs.writeFileSync('/tmp/builds/job-101/output.log', data)):
SymbolicLink header with path: 'config.json/.' and linkpath: '../../../../etc/passwd' (or uses chained symlinks s1 -> . and output.log -> s1/../../../../app/server.js)./tmp/builds/job-101/ using tar.x({ file: 'upload.tar', cwd: '/tmp/builds/job-101' }).node-tar 7.5.24, the symlink /tmp/builds/job-101/config.json (or output.log) is created on disk without raising a TAR_ENTRY_ERROR.config.json to render build settings in the user interface, it discloses /etc/passwd. When the application writes to output.log, the operating system follows the symlink and overwrites /app/server.js, achieving remote code execution on the host.CVE-2026-140248 carries a CVSS v4.0 Base Score of 7.2 (High) with the vector string 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 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 an unauthenticated attacker can deliver a maliciously crafted archive over the network to any service that unpacks archives. User Interaction is rated Passive (UI:P) for scenarios where a user or automated pipeline processes an external package or archive.
The primary security impact is on Vulnerable System Integrity (VI:H). When an application or automated workflow writes data to files within an extracted archive directory without using O_NOFOLLOW or verifying fs.realpathSync, a planted symlink allows the attacker to redirect those writes to arbitrary files writable by the Node.js process. In build systems, plugin loaders, or web backends, overwriting application source files, .bashrc, SSH authorized_keys, or executable binaries in node_modules/.bin directly leads to arbitrary code execution.
Confidentiality and Availability impacts are rated Low (VC:L, VA:L). Confidentiality is compromised when an application extracts an archive and subsequently serves, packs, or parses files from the extraction directory (such as a static asset hosting service or an archive conversion utility), allowing the attacker to read arbitrary local files accessible to the Node.js process. Availability is impacted if an attacker directs file writes to overwrite critical application state or configuration files, causing service disruption.
The scope of affected versions is confined to the 7.5.22, 7.5.23, and 7.5.24 releases of node-tar, spanning from July 24, 2026 (when commit 2a22bfc5d3a432a606d9da0e2d87ba634aa3b1cb was released in v7.5.22) to November 27, 2026 (when v8.0.0 was released). Currently, CVE-2026-140248 is not listed in the CISA Known Exploited Vulnerabilities (KEV) catalog.
The primary remediation is to upgrade the tar dependency to version 8.0.0 or later, which includes commit 23b368128b6cf7d4c26f2e302c0e4a82f70a6e3d. Administrators and developers can update their package.json and lockfiles using standard npm commands:
npm install tar@^8.0.0> [!NOTE]
> Version 8.0.0 introduces breaking architectural changes to node-tar. It requires Node.js >= 22, replaces Node.js streams and callback APIs with Promises and web standard ReadableStream interfaces, and moves Node-specific synchronous APIs (extractSync, createSync) to the 'tar/node' sub-path export (import * as tar from 'tar/node').
For environments that cannot immediately migrate to Node.js >= 22 and tar@8.0.0, applications running node-tar 7.5.22 through 7.5.24 must implement an explicit entry filter callback on all extraction calls (tar.x / tar.extract, tar.Unpack). This filter should replicate the patch logic from 8.0.0 by normalizing entry.path and rejecting any SymbolicLink entry that contains .. after a named component or escapes the normalized directory:
const path = require('node:path')
const tar = require('tar')
function secureSymlinkFilter(entryPath, entry) {
if (entry.type === 'SymbolicLink') {
// 1. If symlinks are not required by the application, reject all symlinks:
// return false;
// 2. Replicate v8.0.0 linkpath validation if symlinks must be allowed:
const linkpath = entry.linkpath || ''
const parts = linkpath.replace(/\\/g, '/').split('/')
const firstName = parts.findIndex(
part => part !== '..' && part !== '.' && part !== ''
)
if (firstName !== -1 && parts.includes('..', firstName)) {
return false
}
const normalizedEntryPath = path.posix.normalize(
entryPath.replace(/\\/g, '/').replace(/^\/+/, '')
)
const entryDir = path.posix.dirname(normalizedEntryPath)
const resolved = path.posix.normalize(
path.posix.join(entryDir, parts.join('/'))
)
if (resolved.startsWith('../') || resolved === '..' || path.posix.isAbsolute(resolved)) {
return false
}
}
return true
}
// Usage during extraction:
tar.x({
file: 'untrusted-archive.tar',
cwd: '/app/extraction-root',
preservePaths: false,
strict: true,
filter: secureSymlinkFilter,
})If the application's functional requirements do not require symbolic links or hard links inside user-supplied archives, the safest defense-in-depth policy is to reject all link entries unconditionally within the filter function by checking if (entry.type === 'SymbolicLink' || entry.type === 'Link') return false. Additionally, downstream code that processes extracted files should verify canonical paths using fs.realpathSync() and confirm the resolved path starts with the extraction directory prefix before reading or writing.
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 |
|---|---|---|
tar (node-tar) Isaac Z. Schlueter (isaacs) | >= 7.5.22, < 8.0.0 | 8.0.0 |
| Attribute | Detail |
|---|---|
| CVE / Advisory ID | CVE-2026-140248 / GHSA-6wwr-g865-f46r |
| Weakness Class | CWE-59: Improper Link Resolution Before File Access ('Link Following') |
| 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 | tar (node-tar) on npm (>= 7.5.22, < 8.0.0) |
| Patched Version | 8.0.0 (Commit 23b368128b6cf7d4c26f2e302c0e4a82f70a6e3d) |
| Attack Vector | Network / Crafted Tar Archive Extraction with Chained or Unnormalized Symlinks |
| Primary Impact | Symlink Escape from Extraction Root Leading to Arbitrary File Overwrite or Read |
| CISA KEV Status | Not Listed |
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 outside of the intended control sphere.
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.
CVE-2026-140014 (also tracked as GHSA-8wcq-xq25-7fhm and RUSTSEC-2026-0594) is a cryptographic weakness in the Rust cookie library (cookie-rs). Affected versions use userspace thread-local pseudo-random number generators (rand::thread_rng() or rand::rng()) to generate 96-bit nonces for AES-256-GCM encrypted cookies in PrivateJar. Because these generators buffer entropy in userspace memory, invoking a Unix fork() system call without exec() clones the internal RNG buffer into child processes. When sibling or parent-child processes subsequently seal private cookies on the same thread using a shared key, they emit identical nonces. This nonce reuse under AES-GCM compromises ciphertext confidentiality via keystream XOR recovery and enables arbitrary cookie forgery via polynomial GHASH authentication key recovery.