Fix Zip Slip vulnerability in archive extraction#296
Conversation
Co-authored-by: slachiewicz <6705942+slachiewicz@users.noreply.github.com>
Co-authored-by: slachiewicz <6705942+slachiewicz@users.noreply.github.com>
--------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: slachiewicz <6705942+slachiewicz@users.noreply.github.com> (cherry picked from commit 6d780b3)
--------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: slachiewicz <6705942+slachiewicz@users.noreply.github.com> (cherry picked from commit 6d780b3)
|
Can we have this backported to 3.x line as well? |
|
NVM, missed it is already backported to 3.x |
|
@cstamas it has been backported but I don't see a 3.x release so it's still an issue, right? |
|
Right, 3.x branch has the fix, but 3.6.0 is last release, 3.6.1 yet to happen. |
|
@slachiewicz 👋 is there a plan for releasing a 3.x for Maven 3 consumption? Thanks! |
|
We have had a request to update the ruby-maven-libs Ruby gem to include this change. ruby-maven-libs is just a container for a complete Maven 3.x distribution, and we would prefer not to have to patch individual elements of that distribution. Therefore we are also interested in this update getting into a Maven 3 release. |
|
Plexus Utils 3.6.1 w/ fix is released. For Maven 3.9.x it may take some more time. Also, Maven 3.10.x is in preparation (goal is Resolver 2.x shipped with it). |
Summary
Fixes the Zip Slip vulnerability (arbitrary file write during archive extraction) in the
Expandclass by improving path validation to prevent directory traversal attacks.Resolves: https://github.com/codehaus-plexus/plexus-utils/security/code-scanning/1
Problem
The Zip Slip vulnerability is a form of directory traversal attack that allows a malicious zip file to write files outside the intended extraction directory. The original validation in
Expand.extractFile()was insufficient:This check had two critical flaws:
/tmp/extract-evil/malicious.txtwhen extracting to/tmp/extractbecause the absolute path string starts with the target directory prefixSolution
The fix uses canonical paths and adds a file separator to the directory path check to prevent prefix matching attacks:
Test Coverage
Added comprehensive test cases in
ExpandTest.java:../../evil.txt)Verification
The fix is minimal and surgical, changing only 13 lines in the security-critical path validation logic.
Original prompt
Fixes #248
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.