Visit the Wiz Whimzical Shop at AWS re:Invent
Vulnerability DatabaseGHSA-p4w4-63wp-74wq

GHSA-p4w4-63wp-74wq: 
JavaScript vulnerability analysis and mitigation

Summary

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.

Root Cause

In src/header.ts:

  • Lines 140-141: if (this.#type === '0' && this.path.slice(-1) === '/') { this.#type = '5' } coerces a trailing-slash regular file to Directory.
  • Lines 149-151: 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.

Impact

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.

Proof of Concept

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 slash

The two controls prove the divergence is caused specifically by the trailing-slash 0->5 coercion combined with native-size zeroing.

Attack Chain

  1. Entry: malicious npm tarball parsed by node-tar (tar.x / tar.t). Carrier header name=pkg/, typeflag=0, native size=octal(1024).
    • Guard: none at entry — any consumer parsing an untrusted tar is reachable, unauthenticated.
    • Bypass proof: no auth or configuration required.
  2. Check: src/parser.ts:361-366 abort for "Directory entry with a body".
    • Guard: (size && noBodyTypes.has(type)) || (type === 'Directory' && ex?.size).
    • Bypass proof: header.size already 0 (zeroed at header.ts:150) and ex?.size is undefined (no PAX) -> both disjuncts falsy -> no abort.
  3. Processing: header.ts:140 coerces 0->5 (trailing slash); header.ts:150 sets size=0; parser #remain=#blockRemain=0 (parser.ts:382-383).
    • Guard: none.
    • Bypass proof: control archive with native type 5 reproduces 4 entries across ALL parsers, isolating the coercion.
  4. Sink: next next() iteration treats offset+512 as a fresh header -> emits pkg/.bin/evil, pkg/postinstall.js as real File entries; Unpack extracts them.
  5. Impact: files invisible to a GNU-tar/Python-tarfile scanner are extracted by npm -> supply-chain scanner evasion.

Bypass Evidence

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.

Affected Versions

<= 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.

Suggested Fix

When coercing a trailing-slash type-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

Related JavaScript vulnerabilities:

CVE ID

Severity

Score

Technologies

Component name

CISA KEV exploit

Has fix

Published date

GHSA-7cfw-w2rf-f3jcMEDIUM5.3
  • JavaScript logoJavaScript
  • fast-xml-parser
NoYesDec 01, 2026
CVE-2026-141514LOW3.7
  • JavaScript logoJavaScript
  • minimatch
NoYesDec 01, 2026
GHSA-844h-fxvq-x544LOWN/A
  • JavaScript logoJavaScript
  • tar
NoYesDec 02, 2026
GHSA-8282-h5g3-523jLOWN/A
  • JavaScript logoJavaScript
  • tar
NoYesDec 02, 2026
GHSA-p4w4-63wp-74wqLOWN/A
  • JavaScript logoJavaScript
  • tar
NoYesDec 02, 2026

Free Vulnerability Assessment

Benchmark your Cloud Security Posture

Evaluate your cloud security practices across 9 security domains to benchmark your risk level and identify gaps in your defenses.

Request assessment

Additional Wiz resources

Get a personalized demo

Ready to see Wiz in action?

"Best User Experience I have ever seen, provides full visibility to cloud workloads."
David EstlickCISO
"Wiz provides a single pane of glass to see what is going on in our cloud environments."
Adam FletcherChief Security Officer
"We know that if Wiz identifies something as critical, it actually is."
Greg PoniatowskiHead of Threat and Vulnerability Management