CVE-2026-140249: CVE-2026-140249: Path Traversal via Lexical Symlink Normalization in node-tar
CVE-2026-140249: Path Traversal via Lexical Symlink Normalization in node-tar Vulnerability ID: CVE-2026-140249 CVSS Score: 7.2 Published: 2026-12-02 CVE-2026-140249 (also tracked as GHSA-4pf9-5fpx-xmr6) is a path t
CVE-2026-140249: Path Traversal via Lexical Symlink Normalization in node-tar
Vulnerability ID: CVE-2026-140249
CVSS Score: 7.2
Published: 2026-12-02
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.
TL;DR
A path traversal flaw in node-tar (>= 7.5.5, < 8.0.0) allows attackers to create symbolic links pointing outside the target extraction directory via lexical path normalization bypasses. When downstream application logic reads from or writes to the extracted files, it follows the planted symlinks, resulting in arbitrary file read or modification. Upgrade to node-tar version 8.0.0 or later to resolve this issue.
β οΈ Exploit Status: POC
Technical Details
- Vulnerability Type: Path Traversal & Improper Symlink Resolution (CWE-22 / CWE-59)
- Affected Component: node-tar (src/unpack.ts) >= 7.5.5, < 8.0.0
- Attack Vector: Network / Crafted Tar Archive Extraction (tar.x)
- 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)
- EPSS Score: 0.94% (62.07th Percentile)
- Impact: Arbitrary File Overwrite and Arbitrary File Disclosure via Planted Symlinks
- Exploit Status: Proof of Concept (PoC) Available in Official Test Suite
- Patched Version: node-tar 8.0.0
Affected Systems
- node-tar (npm package: tar) >= 7.5.5, < 8.0.0
- Node.js applications and build tools utilizing node-tar for archive extraction
-
node-tar (tar): >= 7.5.5, < 8.0.0 (Fixed in:
8.0.0)
Code Analysis
Commit: 23b3681
unpack: reject symlink targets that can leave the cwd
File: 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('/')),
)
Exploit Details
- GitHub (Official Fix Commit & Regression Test Suite): Official commit containing test/symlink-linkpath-escape.test.ts, which provides six functional PoC archive layouts demonstrating symlink escape via lexical normalization bypass.
Mitigation Strategies
- Upgrade node-tar (npm package 'tar') to version 8.0.0 or higher across all direct and transitive dependencies.
- Apply an entry filter callback during tar.x() operations to reject SymbolicLink entries entirely or reject linkpaths containing '..' after any named path segment.
- Verify resolved paths on disk using fs.realpath() against the expected extraction root directory before performing post-extraction read or write operations.
- Isolate untrusted archive extraction processes within ephemeral containers or unprivileged chroot environments.
Remediation Steps:
- Run 'npm ls tar' to identify all direct and transitive occurrences of the 'tar' package within the project.
- Update direct dependencies by executing 'npm install tar@^8.0.0'.
- If transitive dependencies are pinned to tar >= 7.5.5 < 8.0.0, add an 'overrides' entry in package.json for 'tar': '^8.0.0' and run 'npm install'.
- If upgrading to 8.0.0 is not immediately possible, configure the 'filter' function in all tar.x() / tar.extract() calls to block SymbolicLink entries or normalize entry.path and disallow '..' after named path segments.
- Deploy updated dependency lockfiles and verify that unit and integration tests pass with the hardened extraction rules.
References
- NVD - CVE-2026-140249 Detail
- CVE.org Record - CVE-2026-140249
- GitHub Advisory Database - GHSA-4pf9-5fpx-xmr6
- node-tar Repository Security Advisory - GHSA-4pf9-5fpx-xmr6
- Fix Commit 23b368128b6cf7d4c26f2e302c0e4a82f70a6e3d (isaacs/node-tar)
- node-tar v8.0.0 Release Notes
- CVEListV5 Official JSON Record for CVE-2026-140249
Read the full report for CVE-2026-140249 on our website for more details including interactive diagrams and full exploit analysis.
Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes β full credit and traffic to the original publisher.