CVE-2026-140247: node-tar Symlink Linkpath Escape Check Is Vulnerability

HIGH
Advisory Identifier: GHSA-gvrf-jx37-rjv5
CWE-59 CWE-22
Published
Advisory Summary

CVE-2026-140247 is a HIGH symlink linkpath escape check is vulnerability (CWE-59: Improper Link Resolution Before File Access ('Link Following')) affecting node-tar libraries in the npm ecosystem. The issue involves symlink linkpath escape check is lexical: '..' after an in-archive symlink creates symlinks outside the extraction directory. Remediation is available by upgrading affected packages to version 8.0.0.

CVE-2026-140247 at a Glance

CVE Identifier CVE-2026-140247
GHSA Identifier GHSA-gvrf-jx37-rjv5
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-140247

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-140247, 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 options, `tar.x()` / `Unpack` / `UnpackSync` can be made to create `SymbolicLink` entries whose targets resolve outside the extraction directory, although the README states that "`Link` and `SymbolicLink` entries are not allowed to target locations outside of the extraction folder". The trick is a `..` segment that follows a symlink created earlier by the same archive: l1 SymbolicLink -> . esc SymbolicLink -> l1/../outside.txt (lexically "outside.txt", actually <cwd>/../outside.txt) escdir SymbolicLink -> l1/.. (lexically ".", actually the parent of cwd) or, to go further up (one level per in-archive directory): p/q/r/s SymbolicLink -> ../../.. (= cwd) x SymbolicLink -> p/q/r/s/../../../victim.txt (lexically "p/victim.txt", actually <cwd>/../../../victim.txt) None of these entries produces a warning, while the direct form (`esc -> ../outside.txt`) is still rejected. The step-2 symlink of the GHSA-83g3-92jg-28cx chain (`a/b/c/up -> ../..`, `a/b/escape -> c/up/../..`) also still points outside the extraction root on 7.5.23; that fix blocked only the step-3 hardlink. ## Affected versions Tested on tar@7.5.23 (latest; main HEAD eb92e17) with Node 18 on Linux, both async and sync extraction, default options. Versions containing the linkpath sanitization added for GHSA-8qq5 / GHSA-83g3 / GHSA-9ppj appear affected. ## Details - `src/unpack.ts` `[STRIPABSOLUTEPATH]` (~L283-301) accepts a symlink linkpath containing `..` when `path.posix.normalize(join(dirname(entry.path), linkpath))` does not start with `../`. This is purely lexical: `l1/../outside.txt` normalizes to `outside.txt`. - `[SYMLINK]` (~L640-660, same logic in `UnpackSync` ~L1099-1119) builds the components passed to `[ENSURE_NO_SYMLINK]` from `path.relative(cwd, path.resolve(dirname(abs), linkpath))`. `path.resolve` collapses `l1/..` before any `lstat`, so the existing symlink component `l1` is never inspected. - The kernel resolves `l1/..` as `<target of l1>/..`; with `l1 -> .` that is the parent of the extraction directory. Because `l1` is never inspected and symlink targets resolve lazily, entry ordering and parallel async extraction do not matter. ## Steps to reproduce 1. Build an archive (any tool; e.g. node-tar's own `Header`): ```js const fs = require('fs'), tar = require('tar') const hdr = (p, l) => { const b = Buffer.alloc(512); new tar.Header({ path: p, type: 'SymbolicLink', linkpath: l }).encode(b, 0); return b } fs.writeFileSync('evil.tar', Buffer.concat([hdr('l1', '.'), hdr('esc', 'l1/../outside.txt'), hdr('escdir', 'l1/..'), Buffer.alloc(1024)])) fs.writeFileSync('control.tar', Buffer.concat([hdr('esc', '../outside.txt'), Buffer.alloc(1024)])) ``` 2. Extract with default options and then use the extracted tree (same usage model as the GHSA-9ppj PoC): ```js fs.mkdirSync('root/extract', { recursive: true }) fs.writeFileSync('root/outside.txt', 'ORIGINAL\n'); fs.writeFileSync('root/secret.txt', 'DUMMY-SECRET\n') await tar.x({ cwd: 'root/extract', file: 'evil.tar' }) // same with sync: true fs.writeFileSync('root/extract/esc', 'PWNED\n') console.log(fs.readFileSync('root/outside.txt', 'utf8')) // PWNED console.log(fs.readFileSync('root/extract/escdir/secret.txt', 'utf8')) // DUMMY-SECRET ``` Observed on 7.5.23 (repeated runs, async and sync): `control.tar` is rejected with "linkpath escapes extraction directory" and `outside.txt` stays `ORIGINAL`. `evil.tar` yields `warnings=[]`, `realpath(esc)` = `root/outside.txt`, `realpath(escdir)` = `root`; `outside.txt` is overwritten and the outside secret is read. The deeper variant above overwrote a file three directories above `cwd`. ## Impact An attacker-supplied tarball extracted with default options can plant symlinks inside the extraction directory that point to arbitrary files or directories outside it (any depth above the extraction root, controlled by the number of in-archive directories). Any subsequent read or write of the extracted tree by the application — serving files, reading a manifest, writing build output into an extracted folder — then reaches outside the root with the privileges of the extracting user. This is the same impact as GHSA-9ppj-qmqm-q256 and GHSA-8qq5-rm4j-mr97 ("symlink poisoning"), through a different bypass. Suggested CVSS 3.1: `AV:L/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:N` (7.1), mirroring GHSA-83g3-92jg-28cx. ## Suggested fix For `SymbolicLink` entries, do not normalize the linkpath lexically before the check. Walk the raw linkpath components starting from `dirname(entry.absolute)`, `lstat` each existing component before applying the next `..`, and reject the entry if an existing component is a symlink (the rule `[ENSURE_NO_SYMLINK]` already applies to hardlinks). A simpler alternative is to reject any `..` segment that follows a component which currently exists as a symlink. This issue was found with automated analysis (variant analysis) and manually verified.

CVE-2026-140247 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-140247?
CVE-2026-140247 is a security vulnerability in node-tar involving Symlink linkpath escape check is lexical: '..' after an in-archive symlink creates symlinks outside the extraction directory 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-140247?
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-140247?
CVE-2026-140247 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-140247?
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-gvrf-jx37-rjv5",
  "modified" : "2026-12-02T01:01:59Z",
  "published" : "2026-12-02T01:01:59Z",
  "aliases" : [ "CVE-2026-140247" ],
  "summary" : "node-tar: Symlink linkpath escape check is lexical: '..' after an in-archive symlink creates symlinks outside the extraction directory",
  "details" : "## Summary\nWith default options, `tar.x()` / `Unpack` / `UnpackSync` can be made to create `SymbolicLink` entries whose targets resolve outside the extraction directory, although the README states that \"`Link` and `SymbolicLink` entries are not allowed to target locations outside of the extraction folder\". The trick is a `..` segment that follows a symlink created earlier by the same archive:\n\n    l1      SymbolicLink -> .\n    esc     SymbolicLink -> l1/../outside.txt   (lexically \"outside.txt\", actually <cwd>/../outside.txt)\n    escdir  SymbolicLink -> l1/..               (lexically \".\",           actually the parent of cwd)\n\nor, to go further up (one level per in-archive directory):\n\n    p/q/r/s SymbolicLink -> ../../..                     (= cwd)\n    x       SymbolicLink -> p/q/r/s/../../../victim.txt  (lexically \"p/victim.txt\", actually <cwd>/../../../victim.txt)\n\nNone of these entries produces a warning, while the direct form (`esc -> ../outside.txt`) is still rejected. The step-2 symlink of the GHSA-83g3-92jg-28cx chain (`a/b/c/up -> ../..`, `a/b/escape -> c/up/../..`) also still points outside the extraction root on 7.5.23; that fix blocked only the step-3 hardlink.\n\n## Affected versions\nTested on tar@7.5.23 (latest; main HEAD eb92e17) with Node 18 on Linux, both async and sync extraction, default options. Versions containing the linkpath sanitization added for GHSA-8qq5 / GHSA-83g3 / GHSA-9ppj appear affected.\n\n## Details\n- `src/unpack.ts` `[STRIPABSOLUTEPATH]` (~L283-301) accepts a symlink linkpath containing `..` when\n  `path.posix.normalize(join(dirname(entry.path), linkpath))` does not start with `../`. This is purely lexical:\n  `l1/../outside.txt` normalizes to `outside.txt`.\n- `[SYMLINK]` (~L640-660, same logic in `UnpackSync` ~L1099-1119) builds the components passed to\n  `[ENSURE_NO_SYMLINK]` from `path.relative(cwd, path.resolve(dirname(abs), linkpath))`. `path.resolve` collapses\n  `l1/..` before any `lstat`, so the existing symlink component `l1` is never inspected.\n- The kernel resolves `l1/..` as `<target of l1>/..`; with `l1 -> .` that is the parent of the extraction directory.\n\nBecause `l1` is never inspected and symlink targets resolve lazily, entry ordering and parallel async extraction do not matter.\n\n## Steps to reproduce\n1. Build an archive (any tool; e.g. node-tar's own `Header`):\n   ```js\n   const fs = require('fs'), tar = require('tar')\n   const hdr = (p, l) => { const b = Buffer.alloc(512); new tar.Header({ path: p, type: 'SymbolicLink', linkpath: l }).encode(b, 0); return b }\n   fs.writeFileSync('evil.tar', Buffer.concat([hdr('l1', '.'), hdr('esc', 'l1/../outside.txt'), hdr('escdir', 'l1/..'), Buffer.alloc(1024)]))\n   fs.writeFileSync('control.tar', Buffer.concat([hdr('esc', '../outside.txt'), Buffer.alloc(1024)]))\n   ```\n2. Extract with default options and then use the extracted tree (same usage model as the GHSA-9ppj PoC):\n   ```js\n   fs.mkdirSync('root/extract', { recursive: true })\n   fs.writeFileSync('root/outside.txt', 'ORIGINAL\\n'); fs.writeFileSync('root/secret.txt', 'DUMMY-SECRET\\n')\n   await tar.x({ cwd: 'root/extract', file: 'evil.tar' })          // same with sync: true\n   fs.writeFileSync('root/extract/esc', 'PWNED\\n')\n   console.log(fs.readFileSync('root/outside.txt', 'utf8'))              // PWNED\n   console.log(fs.readFileSync('root/extract/escdir/secret.txt', 'utf8')) // DUMMY-SECRET\n   ```\nObserved on 7.5.23 (repeated runs, async and sync): `control.tar` is rejected with \"linkpath escapes extraction directory\" and `outside.txt` stays `ORIGINAL`. `evil.tar` yields `warnings=[]`, `realpath(esc)` = `root/outside.txt`, `realpath(escdir)` = `root`; `outside.txt` is overwritten and the outside secret is read. The deeper variant above overwrote a file three directories above `cwd`.\n\n## Impact\nAn attacker-supplied tarball extracted with default options can plant symlinks inside the extraction directory that point to arbitrary files or directories outside it (any depth above the extraction root, controlled by the number of in-archive directories). Any subsequent read or write of the extracted tree by the application — serving files, reading a manifest, writing build output into an extracted folder — then reaches outside the root with the privileges of the extracting user. This is the same impact as GHSA-9ppj-qmqm-q256 and GHSA-8qq5-rm4j-mr97 (\"symlink poisoning\"), through a different bypass.\n\nSuggested CVSS 3.1: `AV:L/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:N` (7.1), mirroring GHSA-83g3-92jg-28cx.\n\n## Suggested fix\nFor `SymbolicLink` entries, do not normalize the linkpath lexically before the check. Walk the raw linkpath components starting from `dirname(entry.absolute)`, `lstat` each existing component before applying the next `..`, and reject the entry if an existing component is a symlink (the rule `[ENSURE_NO_SYMLINK]` already applies to hardlinks). A simpler alternative is to reject any `..` segment that follows a component which currently exists as a symlink.\n\nThis issue was found with automated analysis (variant analysis) and manually verified.",
  "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-gvrf-jx37-rjv5"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2026-140247"
  }, {
    "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:01:59Z",
    "nvd_published_at" : "2026-12-01T18:17:29Z"
  }
}