node-tarの脆弱性、PAX拡張ヘッダーの解析不備で改ざんされたエントリが展開される
Summary
node-tarの7.5.0から8.0.0までのバージョンには、PAX拡張ヘッダーの解析に不備があり、レコードの値に含まれる改行で元のフィールドが欠落し、偽造されたパスやサイズなどの属性を持つエントリが作られる脆弱性があります。preservePathsを有効にしている場合は、絶対パスや親ディレクトリを含むパスになる可能性もあります。修正版は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.0から8.0.0までのバージョンには、PAX拡張ヘッダーの解析に不備があり、レコードの値に含まれる改行で元のフィールドが欠落し、偽造されたパスやサイズなどの属性を持つエントリが作られる脆弱性があります。preservePathsを有効にしている場合は、絶対パスや親ディレクトリを含むパスになる可能性もあります。修正版は8.0.0です。8.0.0以降へ更新してください。
Affected packages
| Package | Affected → Fixed | |
|---|---|---|
| isaacsnode-tar | — | Not listed |
| npmtar |
≥ 7.5.0, < 8.0.0→ 8.0.0 |
8.0.0 |
Original description The description as published by the source.
Summary
node-tar parses POSIX pax extended headers by splitting the header body on every newline and validating each resulting line's length prefix, instead of consuming length-delimited records as the format specifies. A record whose value contains a newline (which occurs legitimately whenever an archived filename contains a newline) is mishandled two ways: the true record is dropped (the entry falls back to its truncated 100-byte header name), and any post-newline fragment that itself forms a self-valid key=value line is applied as a real extended-header field. This is a cross-implementation divergence and an arbitrary PAX-field injection primitive (path, size, linkpath, mode, uid, gid, mtime) driven by a single attacker-controlled filename or crafted archive.
Details
// src/pax.ts:151-167
const parseKV = (str) =>
str.replace(/\n$/, '').split('\n') // <- splits INSIDE length-valid record values
.reduce(parseKVLine, Object.create(null))
const parseKVLine = (set, line) => {
const n = parseInt(line, 10)
// XXX Values with \n in them will fail this.
// Refactor to not be a naive line-by-line parse.
if (n !== Buffer.byteLength(line) + 1) return set // record dropped when its value contained '\n'
line = line.slice((n + ' ').length)
// ... a forged ' key=value' fragment is then ACCEPTED as a real record
}
POSIX pax records are key=value\n, where `` counts the entire record including any newline inside the value.…
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