Home/Research/Post

GHSA-hqgx-p3r3-2cfg: node-tar: SymbolicLink extraction escapes the extraction directory on non-Windows hosts via a backslash separator differential

  • Severity: HIGH
  • CVE: CVE-2026-140246
  • Ecosystems: npm
  • Packages: tar

### Summary

On a non-Windows host, extracting a crafted tar with default options makes node-tar ( LINK calls fs.symlink(entry.linkpath, entry.absolute) (src/unpack.ts, ~lines 640-660 and 866-881), where “\” is an ordinary filename character.

So a segment like “A\B” counts as TWO segments to the check but ONE to the kernel. Backslash padding inflates the check’s segment count, so a “..” run that the check believes stays inside cwd actually escapes it at creation/resolution time.

Walkthrough for entry.linkpath = “A\B/../../x”:
– CHECK (“\” -> “/”): [“A”,”B”,”..”,”..”,”x”] -> normalizes to “x” -> believed inside cwd -> ALLOWED
– CREATE (Linux, “\” literal): [“A\B”,”..”,”..”,”x”] -> from cwd: cwd/A\B -> .. -> cwd -> .. -> parent of cwd -> ESCAPES

The escape depth equals the number of backslashes in the padding segment (overshooting saturates at “/”), so any path on the same filesystem is reachable regardless of cwd depth.

Why the other guards do not catch it: ENSURE_NO_SYMLINK (src/unpack.ts, ~lines 679-698) only rejects EXISTING symlinks found in the target path, not cwd-escape; and CHECKPATH’s defense-in-depth validates entry.path (the entry’s own path), not the linkpath.

Scope note (per README “Security Information”): this breaks the stated protection “Link and SymbolicLink entries are not allowed to target locations outside of the extraction folder”, so it is reportable under “not properly enforcing the intended security protections”. It is NOT the out-of-scope case in…

Source: GitHub Security Advisories · 2026-12-02