CVE-2026-140245: CVE-2026-140245: Symlink Linkpath Containment Bypass via Trailing Dot Segments in node-tar
CVE-2026-140245: Symlink Linkpath Containment Bypass via Trailing Dot Segments in node-tar Vulnerability ID: CVE-2026-140245 CVSS Score: 7.2 Published: 2026-12-02 CVE-2026-140245 (GHSA-jmj2-9c5q-vw73) is a path trav
CVE-2026-140245: Symlink Linkpath Containment Bypass via Trailing Dot Segments in node-tar
Vulnerability ID: CVE-2026-140245
CVSS Score: 7.2
Published: 2026-12-02
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.
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.
⚠️ Exploit Status: POC
Technical Details
- CVE / Advisory ID: CVE-2026-140245 / GHSA-jmj2-9c5q-vw73
- Weakness Class: CWE-22: Path Traversal (Symlink Containment Bypass)
- 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 Versions: node-tar (tar) >= 7.5.5, < 8.0.0 (7.5.5 - 7.5.24)
- Patched Version: node-tar (tar) 8.0.0
- Attack Vector: Network / Crafted TAR Archive Extraction
- Exploit Status: Proof-of-Concept Available (Regression Test Suite)
- CISA KEV Status: Not Listed
Affected Systems
- node-tar (tar npm package)
-
tar (node-tar): >= 7.5.5, < 8.0.0 (7.5.5 through 7.5.24) (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('/')),
)
Mitigation Strategies
- Upgrade node-tar (tar on npm) to version 8.0.0 or later to apply native path normalization before parent directory evaluation.
- Implement a custom filter callback in tar.extract() to inspect and drop entries with trailing dot segments ('/.' or '/./') or symlink targets that escape the normalized parent directory.
- Ensure the preservePaths option remains disabled (false) across all archive extraction calls processing untrusted inputs.
Remediation Steps:
- Audit project dependency trees using 'npm ls tar' to identify any direct or transitive installations of tar between v7.5.5 and v7.5.24.
- Verify that the deployment runtime meets the Node.js >= 22 requirement for tar v8.0.0, and update package.json to require 'tar': '^8.0.0'.
- If locked to Node.js < 22 and tar v7.x, deploy a filter function in all tar.extract() and tar.x() calls that normalizes entry.path via path.posix.normalize() before checking relative linkpath resolution.
- Run regression tests with crafted symlink headers (such as 'esc/.' pointing to '../outside.txt') to verify that extraction emits TAR_ENTRY_ERROR or filters the entry without writing the symlink to disk.
References
- GitHub Security Advisory: GHSA-jmj2-9c5q-vw73
- Fix Commit: unpack: reject symlink targets that can leave the cwd
- Patch Commit Diff for 23b368128b6cf7d4c26f2e302c0e4a82f70a6e3d
- node-tar Release Notes v8.0.0
- Official CVE Record: CVE-2026-140245
- NVD Vulnerability Detail: CVE-2026-140245
- CVEProject cvelistV5 JSON Record: CVE-2026-140245
- Wiz Vulnerability Database: CVE-2026-140245
Read the full report for CVE-2026-140245 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.