All vulnerabilities

npm

CVE-2026-140244

node-tar: Symlink containment bypass via nested symlink + '..' (lexical linkpath check)

Severity
High
Published
2 Dec 2026
Last changed
2 Dec 2026
Added to UpHeron
2 Dec 2026
Fixed in
8.0.0
Weakness
Path traversal (CWE-22)Link following (CWE-59)
Also known as
GHSA-mhqm-9wj8-w7r4
Sources
OSV.dev and GitHub

Description

node-tar checks that a symlink's target stays inside cwd, but the check is lexical. It runs path.resolve(dirname, linkpath), which collapses .. without following symlinks. Entry 1 s1 -> . is accepted because its target is cwd. Entry 2 s2 -> s1/../secret.txt resolves lexically to /secret.txt and is accepted too. On disk the kernel resolves s1 to cwd first and then applies .., so s2 points to /../secret.txt, outside the extraction root. Repeating s1/ climbs further. node-tar rejects the direct form (../secret.txt gives TAR_ENTRY_ERROR), so it treats outside-pointing symlinks as in scope. This bypasses the linkpath containment added for GHSA-8qq5-rm4j-mr97 and related advisories.

Hardlinks through s1/.. and writes through s2/ are still blocked. The result is a planted symlink pointing outside the extraction root. Anything that later reads, serves, copies or archives the extracted tree follows it, which gives arbitrary file read (for example package installers, build or CI systems, and…

From the GitHub Advisory Database, CC BY 4.0. Shortened; the full text is there.

Affected software

SoftwareAffected versions
tarnpm · osv:npm:tar
  • Every version before 8.0.0

About tar

Weekly downloads (npm)
113,520,680npm, 1 Dec 2026

References