Skip to content
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

Fix zip traversal vulnerability #66

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

ametry
Copy link

@ametry ametry commented Jun 28, 2018

There is a vulnerability where an attacker can create an archive with entries, when extracted, attempt to traverse up the file system then down to overwrite system files, giving the attacker the ability to perform malicious attacks.
This PR fixes this vulnerability by verifying that the file is being created inside the target/destination directory. If it is not, it is forced to be placed inside the directory. The added test cases show different scenarios of attempts to traverse outside the target directory.

I chose to solve the problem using java.nio which is supported starting java 7 hence the change in pom.xml

For more information about the vulnerability, please refer to this blog post https://blog.sonatype.com/making-sure-our-users-dont-zip-slip-and-fall

@thrau
Copy link
Owner

thrau commented Jul 1, 2018

thanks for this contribution, i'm glad to see that people are looking into security aspects of jarchivelib. i have some concerns merging this into master because i'm still planning on releasing a major version that's compatible with java 6 to not break peoples code. i'll gladly merge it into the next major version where java 6 will be dropped (see #22)

@ametry
Copy link
Author

ametry commented Jul 2, 2018

@thrau thanks! Glad to know that you were already planning on using java.nio. I'm curious, is there a rough estimate on when the next major release version might be (when java 6 will be dropped)?

@thrau
Copy link
Owner

thrau commented Jul 2, 2018

i can't give you one at the moment, but in principle i could start a new branch for 2.x and start deploying snapshots for you to use your code.

@ametry
Copy link
Author

ametry commented Jul 2, 2018

Great. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants