
Cloud Vulnerability DB
A community-led vulnerabilities database
When a ustar header declares typeflag 0 (regular file) but has a name ending in /, node-tar reclassifies it to a Directory and then force-zeros its size, discarding the non-zero native ustar size field. The parser then interprets the bytes the header declared as its body as the NEXT header blocks, surfacing entries that both GNU tar and Python tarfile hide. Because npm extracts packages with node-tar, a supply-chain audit scanner built on GNU tar or Python sees a benign archive while npm install (node-tar) extracts the smuggled files.
In src/header.ts:
if (this.#type === '0' && this.path.slice(-1) === '/') { this.#type = '5' } coerces a trailing-slash regular file to Directory.if (this.#type === '5') { this.size = 0 } force-zeros the size, discarding the native ustar size field.
The abort guard in src/parser.ts:361-366 — (size && noBodyTypes.has(type)) || (type === 'Directory' && ex?.size) — only fires on a PAX-supplied ex.size. By the time it runs, header.size is already 0 (zeroed at header.ts:150) and ex?.size is undefined (no PAX header present), so neither disjunct is truthy. The native-size path is unguarded.Interpretation differential (CWE-436): node-tar reads MORE entries than both GNU tar 1.35 and Python tarfile, all three reading the archive cleanly with no error or warning. This violates node-tar's own documented invariant (README §"Archives that tar programs read in different ways"). A scanner/extractor pipeline where node-tar is the extractor (e.g. npm) and the scanner uses GNU/Python lets an attacker smuggle files (e.g. a postinstall.js or a .bin script) past the audit.
Carrier header: name=pkg/, typeflag=0, native size field = octal(1024); immediately followed by two crafted 512-byte headers (pkg/.bin/evil, pkg/postinstall.js) occupying the region the carrier declared as its 1024-byte body; then end blocks.
node-tar : pkg/package.json, pkg/(Directory), pkg/.bin/evil, pkg/postinstall.js warns=[] (4 entries)
GNU 1.35 : pkg/package.json, pkg clean, rc=0 (2 entries)
Python : pkg/package.json, pkg/(size=1024) clean (2 entries)
CONTROL native-type-5 carrier : ALL THREE read 4 entries -> isolates the 0->5 coercion as the cause
CONTROL no-slash name 'pkgX' : ALL THREE read 1 entry (size 1024) -> isolates the trailing slashThe two controls prove the divergence is caused specifically by the trailing-slash 0->5 coercion combined with native-size zeroing.
tar.x / tar.t). Carrier header name=pkg/, typeflag=0, native size=octal(1024).src/parser.ts:361-366 abort for "Directory entry with a body".(size && noBodyTypes.has(type)) || (type === 'Directory' && ex?.size).header.size already 0 (zeroed at header.ts:150) and ex?.size is undefined (no PAX) -> both disjuncts falsy -> no abort.header.ts:140 coerces 0->5 (trailing slash); header.ts:150 sets size=0; parser #remain=#blockRemain=0 (parser.ts:382-383).5 reproduces 4 entries across ALL parsers, isolating the coercion.next() iteration treats offset+512 as a fresh header -> emits pkg/.bin/evil, pkg/postinstall.js as real File entries; Unpack extracts them.On-disk reproduction with external GNU tar 1.35 and Python 3.14.7 tarfile (not just the in-process harness), independently rebuilt during final review. node-tar lists 4 entries; both oracles list 2; all three return clean (rc=0, no warning). Control archives (native type-5 carrier; no-slash name) isolate the trailing-slash 0->5 coercion + native-size zeroing as the sole cause.
<= 8.0.4 (latest release = HEAD b62c8bb). Code present on tag v8.0.4; no post-tag fix on src/header.ts / src/parser.ts.
0 to Directory, do not silently discard a non-zero native size — either extend the parser.ts:361-366 "Directory entry with a body" abort to cover the native size field (before it is zeroed), or skip the declared body blocks rather than re-parsing them as headers.Reported by zx (Jace) — GitHub: @manus-use
Source: NVD
Free Vulnerability Assessment
Evaluate your cloud security practices across 9 security domains to benchmark your risk level and identify gaps in your defenses.
Get a personalized demo
"Best User Experience I have ever seen, provides full visibility to cloud workloads."
"Wiz provides a single pane of glass to see what is going on in our cloud environments."
"We know that if Wiz identifies something as critical, it actually is."