GHSA-jmj2-9c5q-vw73

Suggest an improvement
Source
https://github.com/advisories/GHSA-jmj2-9c5q-vw73
Import Source
https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2026/12/GHSA-jmj2-9c5q-vw73/GHSA-jmj2-9c5q-vw73.json
JSON Data
https://api.osv.dev/v1/vulns/GHSA-jmj2-9c5q-vw73
Aliases
Published
2026-12-02T01:09:38Z
Modified
2026-12-02T01:45:50Z
Severity
  • 7.2 (High) CVSS_V4 - 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 CVSS Calculator
Summary
node-tar: Symlink linkpath containment bypass via entry paths ending in '/.'
Details

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.

Database specific
{
    "cwe_ids":  [
        "CWE-22"
    ],
    "github_reviewed":  true,
    "github_reviewed_at":  "2026-12-02T01:09:38Z",
    "nvd_published_at":  "2026-12-01T18:17:28Z",
    "severity":  "HIGH"
}
References

Affected packages

npm / tar

Package

Affected 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"