{"id":"GHSA-jmj2-9c5q-vw73","summary":"node-tar: Symlink linkpath containment bypass via entry paths ending in '/.'","details":"### Summary\n\nA relative symlink linkpath is validated against path.posix.dirname(entry.path) but created at path.resolve(cwd, entry.path). An entry named 'x/.' shifts the check's base one level shallower, so one '..' is absorbed by the check and the link still escapes the extraction directory, with default options and no warning. Regression in 7.5.5-7.5.22 (introduced by the #450 fix).\n\n### Details\n\n### Mechanism\n\n`[STRIPABSOLUTEPATH]` resolves a relative `linkpath` against `path.posix.dirname(entry.path)` (`src/unpack.ts:286`), but the link is created at `path.resolve(cwd, entry.path)` (`src/unpack.ts:359`).\n\nFor an entry name ending in `/.`, `dirname` returns a base one level shallower than the directory the link is actually created in. The check therefore normalises `x/../outside/secret.txt` to `outside/secret.txt`, which passes `startsWith('../')` at `:291`, while the kernel resolves the link from `cwd` and lands outside the destination.\n\n### Affected\n\n`\u003e= 7.5.5, \u003c= 7.5.22`. The regression was introduced by `e9a1ddb` (the #450 relative-linkpath fix). `7.5.4` rejects the entry with `linkpath contains '..'`.\n\n### Fix\n\n```ts\nconst base = path.posix.dirname(normalize(entry.path))\n```\n\nUsing the same base the filesystem will use makes the check and the write agree. Verified against a 1,464-pair property corpus: 300 buggy pairs rejected, 0 legitimate pairs rejected, 0 new accepts; 677 existing tests pass.\n\n### Notes\n\nDistinct from GHSA-9ppj-qmqm-q256: that finding is a malicious *linkpath* string (`C:..`); here the linkpath is ordinary and the defect is the entry-path base computation. #450 introduced this code, so it is the regression rather than a duplicate.\n\n### Proof of concept\n\nReproduced against the npm-published `tar@7.5.22` (not only a source checkout), with one archive entry and default options:\n\n```js\n{ path: 'x/.', type: 'SymbolicLink', linkpath: '../outside/secret.txt' }\n```\n\n```\npad    x -\u003e ../outside/secret.txt   realpath resolves outside dest   warnings: []\nctrl   path 'x' (no '/.')           rejected: \"linkpath escapes extraction directory\"\nstrip  strip:1 (pacote/npm path)    x -\u003e ../outside/secret.txt        warnings: []\n7.5.4  baseline                     rejected: \"linkpath contains '..'\"\n```\n\nThe `x/.` entry is created with the escaped target, with default options, and emits no warning. It also works with `strip: 1`, PAX `path` and GNU `L`.\n\nPoC and controls: `poc-linkpath-pad.mjs` plus a version-regression script (7.5.2 vs 7.5.22).\n\n### Impact\n\nA crafted archive can create a symlink pointing outside the extraction directory using default options and without any warning.\n\n`node-tar`'s own subsequent entries cannot follow the link — `mkdir` refuses symlink parents and file writes use `O_NOFOLLOW` — so the outside write is **consumer-mediated**: a caller that later writes through the extracted path writes outside the destination. This is the same impact model as the accepted GHSA-9ppj-qmqm-q256 / CVE-2026-31802, and it is not claimed to be an in-library write or npm RCE.","aliases":["CVE-2026-140245"],"modified":"2026-12-02T01:45:50.777856678Z","published":"2026-12-02T01:09:38Z","database_specific":{"github_reviewed_at":"2026-12-02T01:09:38Z","nvd_published_at":"2026-12-01T18:17:28Z","cwe_ids":["CWE-22"],"severity":"HIGH","github_reviewed":true},"references":[{"type":"WEB","url":"https://github.com/isaacs/node-tar/security/advisories/GHSA-jmj2-9c5q-vw73"},{"type":"ADVISORY","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-140245"},{"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"}],"affected":[{"package":{"name":"tar","ecosystem":"npm","purl":"pkg:npm/tar"},"ranges":[{"type":"SEMVER","events":[{"introduced":"7.5.5"},{"fixed":"8.0.0"}]}],"database_specific":{"source":"https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2026/12/GHSA-jmj2-9c5q-vw73/GHSA-jmj2-9c5q-vw73.json"}}],"schema_version":"1.9.2","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"}]}