-
-
Notifications
You must be signed in to change notification settings - Fork 8.8k
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
[JENKINS-56931] handle absolute paths correctly when unzipping #3425
Conversation
I'm not sure which tests are failing - couldn't find any on the link, but a bunch of linux tests were skipped. |
Test failure is unrelated, we have an infra issue after the weekly release: |
@aviadatsnyk Could you please create a JIRA ticket for it. If 2.120 gets elected as LTS, we may need t backport it |
@aviadatsnyk Don't you mean absolute paths? |
@daniel-beck according to StackOverflow and getCanonicalPath docs I think we need canonical paths here, to avoid edge cases like |
@oleg-nenashev I'd be happy to open a JIRA, could you please point me to an example similar ticket or some guidlines? I wouldn't like to mess things up in JIRA, and I noticed y'all are very organized with it. |
@aviadatsnyk Was more of a comment about the PR description. The paths you're concerned about here are absolute paths in the zip file that happen to end up within the destination dir -- or I don't understand what this does. |
@daniel-beck you're right. fixed the PR title and the commit message. |
When checking that an unzipped file does not break out of the target directory - this handles '..' in absolute paths correctly, where the previous implementation might not.
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.
I completely missed updates in this PR, sorry. After some reviews, I believe this is a reasonable code quality improvement which we could merge. I will create a JIRA issue and update the changelog
CC @Wadeck @jeffret-b @jvz who might be interested to double-check
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.
Makes sense to me.
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.
Looks good. It's good to get caught up on ones like this and get them merged in.
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.
Thank you for the contribution @aviadatsnyk.
I would strongly appreciate a test demonstrating the things that are fixed with this PR.
I don't know if this is even possible under jenkins, but it's a bug nonetheless.
My point here is that a bug that is just hypothetical but not happening in reality, is not really a bug, right? If you can at least try to write a test to demonstrate what is fixed, would be nice.
If you can't make a "regular" test working there, perhaps you can try to just call the private method using reflection or marking the method as internal (no access modifier).
Test failures look like #3962, retriggering anew to see the PR build status updated at least. |
@Wadeck - this can totally happen in reality. All you need is a JAR for a plugin that is malicious, something like https://github.com/snyk/zip-slip-vulnerability/tree/master/archives Testing this will probably be not trivial, since we'll need to look at the file system to see the difference. |
Given the number of approvals, this seems ready for merge. I would also have appreciated an additional test, but going to consider the majority of reviewers, many from the security team, as sufficient I think. |
If it's the only thing that is not trivial, I think we can collaborate with you to create that test. |
Failure seems related to infra, which was partly improved by #3962, retriggering given this was previously building fine the days before without any new change (and I don't believe changes on |
After looking at the code, the bug is not reachable from regular code. You need to provide a relative I took the opportunity to add tests to cover this case but also the initial one you wrote.
|
thank you @Wadeck ! |
\o/ Thanks @Wadeck for the test addition. Thanks a lot @aviadatsnyk for the fix! I guess we can now really say this is ready for merge. I'll merge this later today or tomorrow, if nobody objects or does it in the meantime. Thanks everyone! |
When checking that an unzipped file does not break out of the target directory - this handle relative paths correctly, where the previous implementation might not. This should prevent a bug that might have been introduced in #3402. For example: if the target directory is
./the-dir
and the unzipping happens in/a/b/c
an archive with a file path/a/b/c/the-dir
which should be legal, will throw an exception.I don't know if this is even possible under jenkins, but it's a bug nonetheless.
See JENKINS-56931.
Proposed changelog entries
Submitter checklist
* Use the
Internal:
prefix if the change has no user-visible impact (API, test frameworks, etc.)Desired reviewers