CVE-2026-140245
JSON

7.2high

node-tar: Symlink linkpath containment bypass via entry paths ending in '/.'

Severity
7.2high CVSS:4.0 by GitHub_M
Published
Last changed
Assigned by
GitHub_M
Also known as
GHSA-jmj2-9c5q-vw73

Description

node-tar is a tar archive manipulation library for Node.js. From 7.5.5 until 8.0.0, symlink linkpath containment bypass via entry paths ending in '/.'. A crafted archive can create a symlink pointing outside the extraction directory using default options and without any warning. The affected security path includes [STRIPABSOLUTEPATH], linkpath, path.posix.dirname(entry.path). This issue is fixed in version 8.0.0.

Affected

Product or packageVersionsReported by
isaacs node-tar>= 7.5.5, < 8.0.0CVE List
tar (npm)from 7.5.5 before 8.0.0GitHub Advisory Database

All scores

GitHub_M7.2high CVSS:4.0CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:P/VC:L/VI:H/VA:L/SC:N/SI:N/SA:N
GitHubhigh CVSS:4.0CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:P/VC:L/VI:H/VA:L/SC:N/SI:N/SA:N

Classification

What each source says

CVE List

node-tar is a tar archive manipulation library for Node.js. From 7.5.5 until 8.0.0, symlink linkpath containment bypass via entry paths ending in '/.'. A crafted archive can create a symlink pointing outside the extraction directory using default options and without any warning. The affected security path includes [STRIPABSOLUTEPATH], linkpath, path.posix.dirname(entry.path). This issue is fixed in version 8.0.0.

GitHub Advisory Database
Summary

A 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).

Details
Mechanism

[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).

For 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.

Affected

>= 7.5.5, <= 7.5.22. The regression was introduced by e9a1ddb (the #450 relative-linkpath fix). 7.5.4 rejects the entry with linkpath contains '..'.

Fix
const base = path.posix.dirname(normalize(entry.path))

Using 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.

Notes

Distinct 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.

Proof of concept

Reproduced against the npm-published tar@7.5.22 (not only a source checkout), with one archive entry and default options:

{ path: 'x/.', type: 'SymbolicLink', linkpath: '../outside/secret.txt' }
pad    x -> ../outside/secret.txt   realpath resolves outside dest   warnings: []
ctrl   path 'x' (no '/.')           rejected: "linkpath escapes extraction directory"
strip  strip:1 (pacote/npm path)    x -> ../outside/secret.txt        warnings: []
7.5.4  baseline                     rejected: "linkpath contains '..'"

The 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.

PoC and controls: poc-linkpath-pad.mjs plus a version-regression script (7.5.2 vs 7.5.22).

Impact

A crafted archive can create a symlink pointing outside the extraction directory using default options and without any warning.

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.

References

Sources

SourceRecordLicence
CVE ListCVE-2026-140245 changed 2026-12-01CVE Terms of Use
GitHub Advisory DatabaseGHSA-jmj2-9c5q-vw73 changed 2026-12-02CC-BY-4.0
NVDCVE-2026-140245 changed 2026-12-01Public domain