Node.js ZipFile returns attacker-controlled prefix bytes after failed ZIP header validation
A flaw in Node.js's zlib.ZipFile API means that when an archive's local header does not match its central directory, the validation error is caught but the parsed local header stays cached without a content offset. A later content read then returns attacker-controlled bytes from the start of the file rather than rejecting the archive, so a Node.js-based scanner can approve different content from what another ZIP implementation extracts.
Originally disclosed on HackerOne
- Triaged in 17 hours
- Fixed in 45 days
- Disclosed after 3 months
Summary by the program
A flaw in the Node.js zlib.ZipFile API can cause it to return bytes that do not belong to the requested entry after the local and central header validation fails.
When zipEntry.modified is read on an archive whose local header does not match its central directory, either directly or while compacting the archive, the validation error is caught but the parsed local header is left cached without a content offset. A later content read then returns attacker-controlled bytes from the start of the file instead of rejecting the archive, and CRC-32 verification still passes because the attacker controls the central directory CRC. A Node.js-based scanner can therefore approve different content from what another ZIP implementation extracts from the same archive.
This vulnerability affects Node.js 26.x.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Impact
A Node.js-based scanner could approve content that differs from what another ZIP implementation extracts from the same archive, though the text does not show a full exploit.
What the attacker needed
Crafted ZIP archive; local header mismatches central directory; code reads zipEntry.modified then content
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
A ZIP file stores information about each file inside it in two places, and normally these two records should agree. This report says that when they disagree, Node.js notices the problem but then carries on and hands back the wrong bytes, taken from the beginning of the archive. Because the attacker also controls the checksum stored in the archive, the wrong content still looks valid, so a tool built on Node.js may clear a file that other ZIP tools would read differently.
What is Business logic?
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.