Conversation
dkhawk
marked this pull request as ready for review
September 23, 2026 00:33
Contributor
Code Coverage
Files
|
…ctory entries Fixes #1790 KMZ directory entries (names ending in '/') were previously skipped in KmzParser without reading through CountingInputStream. When ZipInputStream.closeEntry() was subsequently called, it silently inflated and discarded any compressed payload in the directory entry without counting the bytes towards maxKmzUncompressedTotalSize, allowing decompression exhaustion (Zip bomb DoS) to bypass the limit. - Rejects KMZ directory entries carrying unexpected data payloads immediately on byte 1. - Drains unread bytes through CountingInputStream prior to closeEntry() as defense-in-depth. - Adds regression tests in KmzParserTest verifying directory entries with payloads are rejected and empty directory entries parse cleanly.
dkhawk
force-pushed
the
fix/kmz-directory-decompression-limit
branch
from
September 23, 2026 00:45
6d4f6b2 to
b426719
Compare
This branch has not been deployed
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.
Fixes #1790
Problem
KMZ directory entries (names ending with
/) were previously skipped inKmzParserwithout reading throughCountingInputStream. WhenZipInputStream.closeEntry()was subsequently called, the underlying runtime implementation silently inflated and discarded any compressed data payload within the directory entry without incrementing the uncompressed byte counter. An attacker could construct an archive containing a directory entry with a large compressed payload (e.g., 512 MiB compressed down to ~500 KB), bypassing the configuredmaxKmzUncompressedTotalSize(50 MiB default) and causing CPU starvation or ANR dialogs.Solution
IOExceptionwithout inflating the rest of the stream.drainEntry(countingStream)prior tozipInputStream.closeEntry()to guarantee that any unread bytes in any entry pass throughCountingInputStreamand count towardsmaxKmzUncompressedTotalSize.Testing
parse rejects directory entry with payload exceeding decompression limitinKmzParserTest, reproducing the failure on unpatched code and verifying rejection with the fix.parse allows legitimate empty directory entriesinKmzParserTestverifying standard KMZ archives with directory entries parse cleanly.