CVE-2026-140248: node-tar Nested Symlink Target Can Escape Vulnerability
HIGHCVE-2026-140248 is a HIGH nested symlink target can escape vulnerability (CWE-59: Improper Link Resolution Before File Access ('Link Following')) affecting node-tar libraries in the npm ecosystem. The issue involves nested symlink target can escape node-tar extraction root. Remediation is available by upgrading affected packages to version 8.0.0.
CVE-2026-140248 at a Glance
How to Fix CVE-2026-140248
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-140248, 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-140248 Affected node-tar Versions
1 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
tar
|
npm |
≥ 7.5.22
< 8.0.0
|
8.0.0
|
References
Frequently Asked Questions
What is CVE-2026-140248?
Which node-tar versions are affected?
What version fixes CVE-2026-140248?
Is tar affected?
What CWE is associated with CVE-2026-140248?
How can I check npm dependencies for CVE-2026-140248?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-6wwr-g865-f46r",
"modified" : "2026-12-02T00:58:18Z",
"published" : "2026-12-02T00:58:18Z",
"aliases" : [ "CVE-2026-140248" ],
"summary" : "node-tar: Nested symlink target can escape node-tar extraction root",
"details" : "## Summary\n\nWith default `preservePaths: false`, `tar` 7.5.22 can extract a symbolic link whose effective target is outside the extraction directory. A crafted archive first creates one in-root symlink and then a second symlink whose target contains that symlink followed by `..`. The containment check simplifies the target lexically before checking filesystem symlinks, but the stored target is resolved by the OS through the first symlink. A later consumer following the extracted link can access a file outside the intended root.\n\nThis was reproduced locally on commit `2a22bfc5d3a432a606d9da0e2d87ba634aa3b1cb` (package version 7.5.22). Earlier versions were not assessed. The PoC only reads a marker that it creates in its own temporary directory. No preexisting file is touched.\n\n## Root cause\n\n`STRIPABSOLUTEPATH` accepts a symlink `linkpath` containing `..` if `path.posix.normalize(path.posix.join(entryDir, linkpath))` appears to stay inside the extraction root (`src/unpack.ts:263-302`). Later, `SYMLINK` derives `parts` using `path.resolve(dirname(entry.absolute), entry.linkpath)` (`src/unpack.ts:640-659`), which also removes `b/..` before `ENSURE_NO_SYMLINK` inspects each component (`src/unpack.ts:679-698`). `LINK` then writes the original unsimplified `entry.linkpath` with `fs.symlink` (`src/unpack.ts:866-880`).\n\nFor `a/b -> ../x` and `a/c -> b/../..`, the lexical check reduces the second target to the extraction root and never checks `a/b`. Actual filesystem traversal follows `a/b` to `x` first and then processes two parent components, ending in the extraction root's parent.\n\n## Safe local PoC\n\nRun from a built checkout of 7.5.22:\n\n```js\nimport { mkdtempSync, mkdirSync, writeFileSync, readFileSync } from 'node:fs'\nimport { tmpdir } from 'node:os'\nimport { join } from 'node:path'\nimport { Header, extract } from 'tar'\n\nconst parent = mkdtempSync(join(tmpdir(), 'node-tar-link-poc-'))\nconst out = join(parent, 'out')\nmkdirSync(out)\nwriteFileSync(join(parent, 'outside-marker.txt'), 'OUTSIDE MARKER\\n')\nconst block = h => {\n const b = Buffer.alloc(512)\n new Header(h).encode(b)\n return b\n}\nconst input = join(parent, 'input.tar')\nwriteFileSync(input, Buffer.concat([\n block({ path: 'x/', type: 'Directory', size: 0 }),\n block({ path: 'a/', type: 'Directory', size: 0 }),\n block({ path: 'a/b', type: 'SymbolicLink', linkpath: '../x', size: 0 }),\n block({ path: 'a/c', type: 'SymbolicLink', linkpath: 'b/../..', size: 0 }),\n Buffer.alloc(1024),\n]))\n\nconst warnings = []\nawait extract({ file: input, cwd: out, onwarn: (code, message) => warnings.push({ code, message }) })\nconsole.log(readFileSync(join(out, 'a/c/outside-marker.txt'), 'utf8').trim())\nconsole.log(warnings)\n// OUTSIDE MARKER\n// []\n```\n\nThe marker is outside `out`; the access passes through a symlink extracted under `out`. This demonstrates the target containment bypass. It does not claim that node-tar itself writes outside `out` while extracting a subsequent member; its existing path checks may stop such an entry.\n\n## Impact and suggested fix\n\nAn attacker needs to supply a tar archive to an application that extracts links and later follows or serves files from the extracted tree. The resulting link crosses the documented default target confinement. The downstream read/write impact depends on that consumer.\n\nValidate link targets using filesystem semantics before accepting them, or conservatively reject a target that traverses `..` after a symlink component. In particular, inspect the unsimplified components before `path.resolve()` removes them. Add a regression case with a symlink component followed by `..`, and assert that the second link is rejected under default options.\n\nCredit goes to GitHub user `@mikkel32` as finder/reporter in the published advisory.",
"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.22"
}, {
"fixed" : "8.0.0"
} ]
} ]
} ],
"references" : [ {
"type" : "WEB",
"url" : "https://github.com/isaacs/node-tar/security/advisories/GHSA-6wwr-g865-f46r"
}, {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2026-140248"
}, {
"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-59" ],
"severity" : "HIGH",
"github_reviewed" : true,
"github_reviewed_at" : "2026-12-02T00:58:18Z",
"nvd_published_at" : "2026-12-01T18:17:29Z"
}
}