-
Notifications
You must be signed in to change notification settings - Fork 0
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
Introduced protections against "zip slip" attacks #3
base: main
Are you sure you want to change the base?
Introduced protections against "zip slip" attacks #3
Conversation
Unable to locate .performanceTestingBot config file |
Seems you are using me but didn't get OPENAI_API_KEY seted in Variables/Secrets for this repo. you could follow readme for more information |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pixeebot[bot]
Thank you for your contribution to this repository! We appreciate your effort in opening pull request.
Happy coding!
Check out the playback for this Pull Request here. |
Thanks @pixeebot[bot] for opening this PR! For COLLABORATOR only :
|
Processing PR updates... |
PR Details of @pixeebot[bot] in elastic-elasticsearch :
|
try (ZipInputStream zipInput = ZipSecurity.createHardenedInputStream(Files.newInputStream(zip))) { | ||
ZipEntry entry; | ||
byte[] buffer = new byte[8192]; | ||
while ((entry = zipInput.getNextEntry()) != null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The buffer size of 8192 bytes might not be optimal for all environments and could lead to performance issues if the zip files are large. Consider making the buffer size configurable or dynamically adjusting it based on the file size to improve performance.
Important Review skippedBot user detected. To trigger a single review, invoke the You can disable this status message by setting the Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
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 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
ZipInputStream
it'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
ZipInputStream
with 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:❌ The following packages couldn't be installed automatically, probably because the dependency manager is unsupported. Please install them manually:
Gradle
Maven
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