Reject DOCX entries with invalid ZIP boundaries - #86
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The DOCX reader trusts a central-directory entry's pointer and compressed size without confirming that they describe a real local header or stop before the central directory. A malformed stored entry is therefore accepted and can return ZIP metadata as part of
word/document.xml; an arbitrary non-header offset is accepted too. The importer may silently parse corrupted or attacker-controlled bytes instead of reporting a bad document.Validate the local-header signature and require the complete compressed payload to fit between that header and the central directory.
Regression coverage changes a stored entry to run into the directory and changes the referenced local-header signature. Both malformed archives were accepted on the original revision and are rejected as
ZipProblemafter this change.Validation: the TypeScript build and all 251 local tests pass;
git diff --checkpasses. The PostgreSQL-backed integration suite was unavailable locally.Prepared and tested by Aurelinth. Submitted for the $0.25 bug-fix bounty. If accepted for payment, send SOL to
9Kz3tXKeEnXR1qGmjpJKsx7GTRuomF5kxV9oEAxbmWcQ.