-
Notifications
You must be signed in to change notification settings - Fork 5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Prevent zipbomb forged headers attacks #980
Comments
Do you know how likely ZIP files with manipulated decompressed size values are for non-ZIP-bomb ZIP files? Because if the uncompressed size value is usually correct (or zero) it would be possible to wrap the |
I guess no legit ZIP files should have forged headers, most unzip tools will likely treat these files as corrupt or unzip will not work. Exactly, for a more precise solution see: |
Sorry but the provided mitigation example in the linked wiki is bad. Just using For details see http://commons.apache.org/proper/commons-compress/zip.html#ZipArchiveInputStream_vs_ZipFile or search for the error |
@eric-therond-sonarsource thank you for report and samples! |
I have made a PR #982. Can someone review it? :) |
PR #982 merged. @sergey-wowwow can you also check latest commit with zip security enhancements. |
The isZipBomb method relies on ZipEntry.getSize to retrieve the size of an uncompressed entry, but getSize is unreliable to protect against zipbomb attacks, indeed, it gets the size from zip file headers which can be forged by an attacker.
For instance, this file zipBombForgedHeaders.zip is the same than zipBomb.zip except that the headers have been forged (compressed size of an entry = uncompressed size of an entry):
The both archives after being uncompressed take several GiB on the disk.
The first zip (ZipBomb.zip) is correctly blocked by jadx but the second not:
./build/jadx/bin/jadx ./zipBombForgedHeaders.zip -d zipbombtest2
The text was updated successfully, but these errors were encountered: