All vulnerabilities

npm

CVE-2026-140246

node-tar: SymbolicLink extraction escapes the extraction directory on non-Windows hosts via a backslash separator differential

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-hqgx-p3r3-2cfg
Sources
OSV.dev and GitHub

Description

On a non-Windows host, extracting a crafted tar with default options makes node-tar (<= 7.5.22, current latest) create a SymbolicLink whose target resolves OUTSIDE the extraction directory, breaking the documented guarantee that "Link and SymbolicLink entries are not allowed to target locations outside of the extraction folder". This allows arbitrary file read / extraction-containment escape (CWE-22 / CWE-59). Confirmed end-to-end on [email protected] with default tar.x() (async and sync), including reading /etc/passwd. It is distinct from, and survives, the drive-relative fixes (GHSA-9ppj-qmqm-q256 / CVE-2026-31802, GHSA-qffp-2rhf-9h96).

Root cause is a separator-handling difference between the containment CHECK and the symlink CREATE.

In Unpack[STRIPABSOLUTEPATH] (src/unpack.ts), the symlink linkpath is split for the ".." containment check AFTER stripped.replaceAll(/\/g, '/') — i.e. "\" is treated as a path separator when counting segments.

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