- Severity: HIGH
- CVE: CVE-2026-140235
- Ecosystems: npm
- Packages: tar
### 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
“`ts
// src/pax.ts:151-167
const parseKV = (str) =>
str.replace(/\n$/, ”).split(‘\n’) // {
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. Splitting on `\n` breaks a record whose value contains a newline into fragments: the leading fragment fails the `n === byteLength+1` check and…
Source: GitHub Security Advisories · 2026-12-02