node-tarの脆弱性、任意のファイルを読み書きされるおそれ
Summary
node-tarの8.0.0より前のバージョンには、PAX拡張ヘッダーによってlinkpathが書き換えられる脆弱性があります。tar.Parserやtar.listを直接使い、その値を信頼しているプログラムでは、任意のファイルを読み書きされるおそれがあります。修正版は8.0.0です。node-tar自身のtar.xやtar.extractは影響を受けないと案内されています。
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より前のバージョンには、PAX拡張ヘッダーによってlinkpathが書き換えられる脆弱性があります。tar.Parserやtar.listを直接使い、その値を信頼しているプログラムでは、任意のファイルを読み書きされるおそれがあります。修正版は8.0.0です。node-tar自身のtar.xやtar.extractは影響を受けないと案内されています。
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
A tar archive with a Global Extended Header (PAX type g) with a linkpath field injects that value into every entry returned by tar.Parser , including plain File and Directory entries, with zero warnings under strict: true. This happens because header.js's #slurp() correctly excludes linkpath from global headers, but read-entry.js's #slurp() does not apply the same filter. Any application that consumes tar.Parser or tar.list() directly and uses entry.linkpath to build paths or create symlinks, without revalidating the value, can be made to read or write files outside the intended directory via a crafted symlink.
Details
There are two separate #slurp() implementations apply Global Extended Header (g-type) fields to parsed state, and they filter different fields.
In src/header.js, #slurp(ex, gex = false) correctly excludes linkpath when gex is true:
// header.js (correct)
if (k === 'linkpath' && gex) continue;
In src/read-entry.js, the equivalent method has no such clause — it only excludes path:
// read-entry.js (bug: linkpath is not excluded)
if (k === 'path' && gex) continue;
// linkpath from the GEX is not filtered here
The execution flow:
parse.jscallsPax.parse(meta, gex, true)→ stores the GEX object, including thelinkpathfieldheader.jsdecode runs#slurp(gex, true)→ correctly skipslinkpath→header.linkpathis emptyconsumeHeader()…
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