node-tarに、アーカイブ展開先の外にシンボリックリンクを作られる脆弱性
Summary
node-tarの7.5.5から8.0.0より前のバージョンに、細工されたアーカイブで展開先の外を指すシンボリックリンクを作られる脆弱性があります。既定の設定のままでも警告なしに起きるため、該当するバージョンを使っているかを確認してください。修正版は8.0.0で、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の7.5.5から8.0.0より前のバージョンに、細工されたアーカイブで展開先の外を指すシンボリックリンクを作られる脆弱性があります。既定の設定のままでも警告なしに起きるため、該当するバージョンを使っているかを確認してください。修正版は8.0.0で、8.0.0以降へ更新することで対応できます。
Affected packages
| Package | Affected → Fixed | |
|---|---|---|
| isaacsnode-tar | — | Not listed |
| npmtar |
≥ 7.5.5, < 8.0.0→ 8.0.0 |
8.0.0 |
Original description The description as published by the source.
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 maliciou…
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