Add compression-ratio check to zip bomb guard, raise entry size cap - #114
Merged
Merged
Conversation
2 tasks
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.
Summary
MAX_ZIP_ENTRY_BYTESto 50GB as a generous backstop on worst-case disk usage.MAX_ZIP_RATIOcheck (declared:compressed size, default 100x) that catches real zip bombs (tiny compressed payload inflating enormously) regardless of the absolute cap, since ratio is what actually distinguishes a bomb from a big well-compressed dataset.us/nj/statewidetest fixture) contain tiny (a few KB) but highly-compressible index files (.gdbtablx,.atx) that legitimately exceed 100x ratio on their own. AddedMIN_RATIO_CHECK_BYTES(500MB) so the ratio check only applies to entries large enough that an extreme ratio could actually threaten disk space - a few KB inflating to a few hundred KB isn't a real risk regardless of ratio.Test plan
test_extreme_compression_ratio_raises_decompression_error,test_low_compression_ratio_entry_does_not_raise, andtest_small_highly_compressible_entry_does_not_raisetoTestZipDecompressTask- the last one reproduces the exact CI failure (a tiny, highly-compressible entry) as a regression test.python3 test.py(full suite, matching CI) - 123/123 passing in the project's Docker test image, includingtest_single_us_nj_statewidewhich failed on the first push.