node-tarの脆弱性、非Windows環境で展開先の外にリンクを作られる
Summary
node-tarの8.0.0より前のバージョンに、非Windows環境でシンボリックリンクの展開先の範囲チェックが崩れる脆弱性があります。細工されたアーカイブを展開すると、展開先の外のパスを指すリンクが作られるおそれがあります。修正版は8.0.0です。node-tarを利用している場合は、8.0.0以降へ更新してください。
AI summary
Produced by SecPulse using an external AI model; it may contain mistakes. Check the original description and references below before acting on it.
node-tarの8.0.0より前のバージョンに、非Windows環境でシンボリックリンクの展開先の範囲チェックが崩れる脆弱性があります。細工されたアーカイブを展開すると、展開先の外のパスを指すリンクが作られるおそれがあります。修正版は8.0.0です。node-tarを利用している場合は、8.0.0以降へ更新してください。
Affected packages
| Package | Affected → Fixed | |
|---|---|---|
| isaacsnode-tar | — | Not listed |
| npmtar |
< 8.0.0→ 8.0.0 |
8.0.0 |
Original description The description as published by the source.
Summary
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 tar@7.5.22 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).
Details
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.
But on non-Windows, normalizeWindowsPath (src/normalize-windows-path.ts) is the identity function, and the symlink is created with the RAW linkpath: SYMLINK -> 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…
Source: CVE.org (CVE Program・cvelistV5) NVD GitHub Advisory
References
- advisory github.com
- advisory nvd.nist.gov
- package github.com
- web github.com
- web github.com
- web github.com
- web github.com