Introduced protections against "zip slip" attacks#32
Introduced protections against "zip slip" attacks#32pixeebot[bot] wants to merge 1 commit intomainfrom
Conversation
| <scope>test</scope> | ||
| </dependency> | ||
|
|
||
| <dependency> |
There was a problem hiding this comment.
This library holds security tools for protecting Java API calls.
License: MIT ✅ | Open source ✅ | More facts
| <artifactId>hamcrest-all</artifactId> | ||
| <version>1.3</version> | ||
| </dependency> | ||
| <dependency> |
There was a problem hiding this comment.
This library holds security tools for protecting Java API calls.
License: MIT ✅ | Open source ✅ | More facts
|
I'm confident in this change, but I'm not a maintainer of this project. Do you see any reason not to merge it? If this change was not helpful, or you have suggestions for improvements, please let me know! |
|
This change shouldn't have any effect on normal unzipping operations -- it should only throw a If there are other concerns about this change, I'd love to hear about them! |
|
This change may not be a priority right now, so I'll close it. If there was something I could have done better, please let me know! You can also customize me to make sure I'm working with you in the way you want. |
This change updates all new instances of ZipInputStream to protect against malicious entries that attempt to escape their "file root" and overwrite other files on the running filesystem.
Normally, when you're using
ZipInputStreamit's because you're processing zip files. That code might look like this:This looks fine when it encounters a normal zip entry within a zip file, looking something like this pseudo-data:
However, there's nothing to prevent an attacker from sending an evil entry in the zip that looks more like this:
Yes, in the above code, which looks like every piece of zip-processing code you can find on the Internet, attackers could overwrite any files to which the application has access. This rule replaces the standard
ZipInputStreamwith a hardened subclass which prevents access to entry paths that attempt to traverse directories above the current directory (which no normal zip file should ever do.) Our changes end up looking something like this:More reading
I have additional improvements ready for this repo! If you want to see them, leave the comment:
... and I will open a new PR right away!
🧚🤖 Powered by Pixeebot
Feedback | Community | Docs | Codemod ID: pixee:java/harden-zip-entry-paths