CVE-2026-140247: CVE-2026-140247: Lexical Path Validation Bypass and Symlink Escape in node-tar
CVE-2026-140247: Lexical Path Validation Bypass and Symlink Escape in node-tar Vulnerability ID: CVE-2026-140247 CVSS Score: 7.2 Published: 2026-12-02 CVE-2026-140247 (GHSA-gvrf-jx37-rjv5) is a high-severity path tr
CVE-2026-140247: Lexical Path Validation Bypass and Symlink Escape in node-tar
Vulnerability ID: CVE-2026-140247
CVSS Score: 7.2
Published: 2026-12-02
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.
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.
⚠️ Exploit Status: POC
Technical Details
- 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
Affected Systems
- node-tar (npm package 'tar')
-
tar: < 8.0.0 (Fixed in:
8.0.0)
Code Analysis
Commit: 23b3681
unpack: reject symlink targets that can leave the cwd
diff --git a/src/unpack.ts b/src/unpack.ts
index f3aa198f..04e2e273 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('/')),
)
Exploit Details
- GitHub Security Advisory: Official security advisory containing proof-of-concept extraction script demonstrating in-archive symlink directory escape.
- GitHub Repository Test Suite: Regression unit tests in test/symlink-linkpath-escape.test.ts demonstrating all three symlink escape bypass vectors.
Mitigation Strategies
- Upgrade node-tar (npm package 'tar') to version 8.0.0 or later.
- Block SymbolicLink and Link archive entry types via the tar.x() filter option when processing untrusted archives that do not require symlinks.
- Validate all extracted files using fs.realpathSync() to verify they resolve inside the designated extraction root before reading or modifying them.
- Perform archive extraction inside isolated temporary containers or restricted chroot filesystems.
Remediation Steps:
- Check current dependency versions using 'npm ls tar' or 'yarn why tar'.
- Verify that the deployment runtime meets the Node.js >= 22 requirement for [email protected].
- Update package.json to require 'tar': '^8.0.0' and run 'npm install' or 'npm audit fix --force'.
- If upgrading to 8.0.0 is blocked by Node.js runtime constraints, add a custom 'filter' callback to all tar.x() / tar.extract() calls to reject SymbolicLink entries or reject linkpaths containing '..' after a named segment.
References
- CVE Record: CVE-2026-140247
- NVD Vulnerability Detail: CVE-2026-140247
- GitHub Security Advisory: GHSA-gvrf-jx37-rjv5
- Official Security Fix Commit in isaacs/node-tar
- node-tar v8.0.0 Release Notes
- GitHub Advisory Database Record (JSON)
- CVE Project Raw v5 Record
Read the full report for CVE-2026-140247 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.