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-140245

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

Alon Barad
Alon Barad
Software Engineer

Dec 2, 2026·10 min read·1 visit

Executive Summary (TL;DR)

An unnormalized path calculation in node-tar (v7.5.5 to v7.5.24) allows crafted symbolic link entries ending in '/.' or '/./' to bypass target containment checks and point outside the extraction root directory.

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.

Vulnerability Overview

The node-tar package (published as tar on the npm registry) is a widely deployed archive creation and extraction library within the Node.js ecosystem. It is frequently utilized by build tools, package managers, and web applications to unpack user-supplied or remotely fetched .tar and .tgz archives. Because archive extraction inherently involves mapping untrusted metadata inside archive headers to local filesystem operations, node-tar relies on an internal sanitization pipeline to confine extracted files and links within a designated working directory (cwd).

In node-tar versions 7.5.5 through 7.5.24, the symlink containment check in the Unpack class fails to normalize the archive entry path prior to determining its parent directory. This flaw is classified under CWE-22 (Improper Limitation of a Pathname to a Restricted Directory). When an archive entry representing a symbolic link includes a trailing dot segment, such as esc/. or esc/./, the validation routine miscalculates the directory depth at which the symbolic link will reside on disk.

As a result of this miscalculation, a symbolic link whose target (linkpath) contains parent directory traversal sequences (..) is evaluated against a deeper directory level than where the operating system ultimately creates the link. The validation check passes silently without emitting a TAR_ENTRY_ERROR warning, even when the default security settings (preservePaths: false) are active.

Once the escaping symbolic link is written to the extraction directory, it points to a parent or sibling directory outside the intended cwd boundary. Any subsequent archive entries that write through this symbolic link, or application post-processing logic that interacts with the extracted file tree, can be redirected to arbitrary locations on the host filesystem.

Root Cause Analysis

The root cause of CVE-2026-140245 lies in an operational asymmetry between how node-tar computes the parent directory of a symbolic link during path validation and how the Node.js filesystem API canonicalizes that same path during symlink creation. Within src/unpack.ts, the [STRIPABSOLUTEPATH] method inspects the linkpath field of symbolic link entries to verify that relative targets do not traverse above the extraction root.

To perform this validation, node-tar attempts to determine the parent directory of the entry being extracted by calling path.posix.dirname(entry.path) and storing the result in entryDir. It then joins entryDir with the normalized components of the symlink's linkpath and applies path.posix.normalize(). If the resulting string equals '..' or begins with '../', the validator flags the entry as escaping the extraction directory and aborts the extraction of that entry.

However, path.posix.dirname() operates purely on lexical path segments without normalizing trailing dot references. When given an unnormalized entry path such as 'esc/.', path.posix.dirname('esc/.') strips the trailing '.' segment and returns 'esc' as the parent directory. When the validator joins 'esc' with a linkpath of '../outside.txt', path.posix.normalize('esc/../outside.txt') resolves to 'outside.txt'. Because 'outside.txt' does not start with '../', the validator concludes that the symlink target remains within the root extraction directory.

When node-tar proceeds to write the symbolic link to the filesystem, it resolves the destination path using path.resolve(cwd, entry.path). Standard path resolution collapses the trailing '/.' segment, mapping 'esc/.' directly to '<cwd>/esc'. Consequently, the symbolic link is created at the root of <cwd> rather than inside a subdirectory named esc. When the operating system kernel resolves the relative target '../outside.txt' from '<cwd>/esc', it evaluates the target relative to '<cwd>', resolving to one level above the extraction root.

Code Analysis

The vulnerability was introduced in commit 26ab90474e642cf00d84a05bcdc2eaf2a19f1581 and remediated in version 8.0.0 via commit 23b368128b6cf7d4c26f2e302c0e4a82f70a6e3d. In the vulnerable implementation of src/unpack.ts, entry.path was passed directly into path.posix.dirname() without normalization.

// File: src/unpack.ts (Vulnerable code prior to 8.0.0)
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
}

In commit 23b368128b6cf7d4c26f2e302c0e4a82f70a6e3d, the maintainer updated src/unpack.ts to address both the trailing dot segment bypass and a related traversal vector involving '..' segments positioned after named directory components in linkpath. The patch modifies the calculation of entryDir and introduces a strict positional check on '..' segments.

// File: src/unpack.ts (Patched in 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 wrapping entry.path in path.posix.normalize() prior to invoking path.posix.dirname(), the patched code ensures that 'esc/.' and 'esc/./' are first reduced to 'esc'. Calling path.posix.dirname('esc') then returns '.', which accurately reflects that the symbolic link will reside in the current working directory. Joining '.' with '../outside.txt' yields '../outside.txt', which triggers the resolved.startsWith('../') condition and blocks the extraction.

> [!NOTE] > In addition to normalizing entry.path, commit 23b368128b6cf7d4c26f2e302c0e4a82f70a6e3d blocks any linkpath that includes a '..' segment following a named path component (e.g., s1/../outside.txt). This prevents multi-step symlink chaining where an earlier path component (s1) is itself a symlink resolving to another location, which would otherwise cause lexical normalization of linkpath to diverge from real filesystem resolution.

Exploitation

Exploiting CVE-2026-140245 requires an attacker to supply a crafted .tar archive to an application using a vulnerable version of node-tar (>= 7.5.5, < 8.0.0). No special extraction flags are needed; the bypass works against the default configuration of tar.extract() or tar.x(). Because standard tar command-line utilities often normalize or strip trailing /. sequences when building archives from the filesystem, an attacker typically constructs the archive headers programmatically or edits the raw 512-byte POSIX tar header blocks directly.

The following proof-of-concept, adapted from the regression tests added in test/symlink-linkpath-escape.test.ts, demonstrates how to construct an in-memory tar archive using node-tar's Header class to bypass containment checks:

import fs from 'node:fs'
import { resolve } from 'node:path'
import { Header, type HeaderData, extract } from 'tar'
 
const makeArchive = (entries: HeaderData[]) =>
  Buffer.concat([
    ...entries.map(e => {
      const block = Buffer.alloc(512)
      new Header({ mode: 0o755, size: 0, ...e }).encode(block, 0)
      return block
    }),
    Buffer.alloc(1024), // End-of-Archive (EOA) null blocks
  ])
 
async function triggerBypass() {
  const root = resolve('./test-env')
  const cwd = resolve(root, 'cwd')
  fs.mkdirSync(cwd, { recursive: true })
  fs.writeFileSync(resolve(root, 'outside.txt'), 'sensitive data')
 
  const archiveFile = resolve(root, 'payload.tar')
  const payload = makeArchive([
    {
      path: 'esc/.',
      linkpath: '../outside.txt',
      type: 'SymbolicLink',
    },
  ])
  fs.writeFileSync(archiveFile, payload)
 
  await extract({
    file: archiveFile,
    cwd,
    onwarn: (code, message) => {
      console.warn(`[${code}] ${message}`)
    },
  })
}

Several structural variants of the entry path can be used to trigger the same miscalculation:

  • Direct trailing dot: Setting path: 'esc/.' and linkpath: '../outside.txt' creates <cwd>/esc pointing to <cwd>/../outside.txt.
  • Trailing dot with trailing slash: Setting path: 'esc/./' and linkpath: '../outside.txt' produces the same result after normalization.
  • Nested directory trailing dot: Extracting a directory 'a' followed by a symlink with path: 'a/esc/.' and linkpath: '../../outside.txt' causes dirname('a/esc/.') to evaluate to 'a/esc' (depth 2) while creating the link at '<cwd>/a/esc' (depth 1).

When triggerBypass() executes on a vulnerable version of node-tar, no warning is passed to the onwarn callback. Inspecting the extraction directory via fs.readlinkSync(resolve(cwd, 'esc')) confirms that the symlink 'esc' has been written to disk pointing to '../outside.txt', resolving directly to the file outside the sandboxed cwd.

Impact Assessment

The primary security impact of CVE-2026-140245 is the subversion of directory confinement during archive extraction, reflected in its CVSS v4.0 base score of 7.2 (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 is remotely exploitable over the network without authentication (AV:N/PR:N) whenever an application accepts and extracts tar archives from external users, or when a developer extracts an untrusted archive locally (UI:P).

The integrity impact on the vulnerable system is High (VI:H). By establishing a symbolic link that points outside the extraction root, an attacker creates a foothold for arbitrary file creation or file overwrite with the permissions of the Node.js process. If the extraction workflow or a subsequent operation writes data through the escaped symlink path, critical application source files, configuration files, or user profiles (such as ~/.ssh/authorized_keys or .bashrc) can be overwritten, leading to remote code execution.

The confidentiality impact is rated Low (VC:L). While creating an outbound symbolic link does not immediately disclose file contents during the extraction call itself, applications that subsequently serve extracted files over HTTP, re-package extracted directories, or read files from the workspace will follow the symbolic link and expose arbitrary files from the host filesystem (MITRE ATT&CK T1005).

The availability impact is also Low (VA:L), stemming from the potential corruption of application files or system configurations via redirected writes. At the time of publication, CVE-2026-140245 is not listed in the CISA Known Exploited Vulnerabilities (KEV) catalog, and no active exploitation campaigns have been recorded.

Remediation

To remediate CVE-2026-140245, affected projects must upgrade the tar dependency to version 8.0.0 or later. Version 8.0.0 incorporates commit 23b368128b6cf7d4c26f2e302c0e4a82f70a6e3d, which normalizes entry.path prior to calculating entryDir and rejects linkpath targets containing '..' segments after named directory components.

> [!IMPORTANT] > Upgrading from tar v7.x to v8.0.0 introduces major breaking changes. Version 8.0.0 requires Node.js 22 or higher, replaces legacy stream architectures with modern Promise and Web Streams APIs, and removes direct dependencies on minipass and minizlib. Applications running on older Node.js runtimes will need to either upgrade their runtime environment or implement an extraction filter workaround.

For environments that cannot immediately migrate to tar v8.0.0 and Node.js 22, developers should implement a custom filter callback inside tar.extract() options to inspect and reject malformed symbolic link entries before they reach the filesystem:

import path from 'node:path'
import * as tar from 'tar'
 
await tar.extract({
  file: 'untrusted.tar',
  cwd: '/path/to/extract',
  preservePaths: false,
  filter: (entryPath, entry) => {
    // Reject any entry path ending in '/.' or '/./'
    if (/\/\.\/?$/.test(entryPath) || entryPath === '.') {
      return false
    }
    if (entry.type === 'SymbolicLink' && entry.linkpath) {
      const parts = entry.linkpath.split('/')
      const firstName = parts.findIndex(
        p => p !== '..' && p !== '.' && p !== ''
      )
      // Reject '..' segments that appear after a named path segment
      if (firstName !== -1 && parts.includes('..', firstName)) {
        return false
      }
      const entryDir = path.posix.dirname(path.posix.normalize(entryPath))
      const resolved = path.posix.normalize(
        path.posix.join(entryDir, parts.join('/'))
      )
      if (resolved.startsWith('../') || resolved === '..') {
        return false
      }
    }
    return true
  },
})

In addition to upgrading or applying strict entry filtering, verify that preservePaths is never set to true when handling untrusted archives, and execute archive extraction processes within an isolated temporary directory using minimal filesystem privileges.

Official Patches

GitHub / isaacsGitHub Security Advisory GHSA-jmj2-9c5q-vw73
GitHub / isaacsFix Commit in isaacs/node-tar
GitHub / isaacsnode-tar v8.0.0 Release Notes

Fix Analysis (1)

Technical Appendix

CVSS Score
7.2/ 10
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 Systems

node-tar (tar npm package)

Affected Versions Detail

Product
Affected Versions
Fixed Version
tar (node-tar)
Isaac Z. Schlueter (isaacs)
>= 7.5.5, < 8.0.0 (7.5.5 through 7.5.24)8.0.0
AttributeDetail
CVE / Advisory IDCVE-2026-140245 / GHSA-jmj2-9c5q-vw73
Weakness ClassCWE-22: Path Traversal (Symlink Containment Bypass)
CVSS v4.0 Score7.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 Versionsnode-tar (tar) >= 7.5.5, < 8.0.0 (7.5.5 - 7.5.24)
Patched Versionnode-tar (tar) 8.0.0
Attack VectorNetwork / Crafted TAR Archive Extraction
Exploit StatusProof-of-Concept Available (Regression Test Suite)
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 '..' or normalize entry directory paths before resolving symlink targets, enabling traversal outside the restricted location.

Vulnerability Timeline

Patch developed in commit 23b368128b6cf7d4c26f2e302c0e4a82f70a6e3d fixing GHSA-jmj2-9c5q-vw73.
2026-11-26
Additional hardening commits merged and node-tar v8.0.0 prepared for release.
2026-11-27
Official CVE-2026-140245 record published by GitHub CNA and indexed by NVD.
2026-12-01

References & Sources

  • [1]GitHub Security Advisory: GHSA-jmj2-9c5q-vw73
  • [2]Fix Commit: unpack: reject symlink targets that can leave the cwd
  • [3]Patch Commit Diff for 23b368128b6cf7d4c26f2e302c0e4a82f70a6e3d
  • [4]node-tar Release Notes v8.0.0
  • [5]Official CVE Record: CVE-2026-140245
  • [6]NVD Vulnerability Detail: CVE-2026-140245
  • [7]CVEProject cvelistV5 JSON Record: CVE-2026-140245
  • [8]Wiz Vulnerability Database: CVE-2026-140245

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

•about 1 hour 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
3 views•13 min read
•about 2 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
4 views•11 min read
•about 3 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
5 views•10 min read
•about 4 hours ago•CVE-2026-140240
7.1

CVE-2026-140240: Resource Exhaustion and Algorithmic Complexity Denial of Service in node-tar

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.

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

CVE-2026-140239: Global Extended Header linkpath Injection in node-tar

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.

Alon Barad
Alon Barad
7 views•12 min read
•about 6 hours ago•CVE-2026-140238
7.2

CVE-2026-140238: PAX Extended Header Newline Injection and File Overwrite in node-tar

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.

Alon Barad
Alon Barad
5 views•14 min read