GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Fix Zip Slip vulnerability in archive extraction by Copilot · Pull Request #296 · codehaus-plexus/plexus-utils

Conversation

Copilot AI commented Oct 10, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Summary

Fixes the Zip Slip vulnerability (arbitrary file write during archive extraction) in the Expand class 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:

if (!f.getAbsolutePath().startsWith(dir.getAbsolutePath())) {
    throw new IOException("Entry '" + entryName + "' outside the target directory.");
}

This check had two critical flaws:

  1. Used absolute paths instead of canonical paths: Didn't account for symbolic links or path normalization
  2. Vulnerable to prefix matching: A malicious entry could write to /tmp/extract-evil/malicious.txt when extracting to /tmp/extract because the absolute path string starts with the target directory prefix

Solution

The fix uses canonical paths and adds a file separator to the directory path check to prevent prefix matching attacks:

try {
    String canonicalDirPath = dir.getCanonicalPath();
    String canonicalFilePath = f.getCanonicalPath();

    // Ensure the file is within the target directory
    // We need to check that the canonical file path starts with the canonical directory path
    // followed by a file separator to prevent path traversal attacks
    if (!canonicalFilePath.startsWith(canonicalDirPath + File.separator)
            && !canonicalFilePath.equals(canonicalDirPath)) {
        throw new IOException("Entry '" + entryName + "' outside the target directory.");
    }
} catch (IOException e) {
    throw new IOException("Failed to verify entry path for '" + entryName + "'", e);
}

Test Coverage

Added comprehensive test cases in ExpandTest.java:

  • Parent directory traversal attacks (../../evil.txt)
  • Absolute path attacks
  • Prefix matching attacks (extracting to similarly-named directories)
  • Regression test for normal zip extraction

Verification

  • ✅ All 249 tests pass (4 new + 245 existing)
  • ✅ CodeQL security scan confirms 0 vulnerabilities
  • ✅ Code formatting and build checks pass
  • ✅ No breaking changes to existing functionality

The fix is minimal and surgical, changing only 13 lines in the security-critical path validation logic.

Original prompt

This section details on the original issue you should resolve

<issue_title>Fix code scanning alert - Arbitrary file write during archive extraction ("Zip Slip")</issue_title>
<issue_description>

Tracking issue for:

  • https://github.com/codehaus-plexus/plexus-utils/security/code-scanning/1
    </issue_description>

Comments on the Issue (you are @copilot in this section)

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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Initial plan
769152a
Copilot AI assigned Copilot and slachiewicz Oct 10, 2025
Copilot AI and others added 2 commits October 10, 2025 20:39
@slachiewicz
Add tests for Zip Slip vulnerability in Expand class
99e422e
Co-authored-by: slachiewicz <[email protected]>
@slachiewicz
Fix Zip Slip vulnerability in Expand.extractFile method
91450e1
Co-authored-by: slachiewicz <[email protected]>
Copilot AI changed the title [WIP] Fix code scanning alert for Zip Slip vulnerability Fix Zip Slip vulnerability in archive extraction Oct 10, 2025
Copilot AI requested a review from slachiewicz October 10, 2025 20:46
@slachiewicz
slachiewicz marked this pull request as ready for review October 11, 2025 08:49
@slachiewicz slachiewicz added the bug Something isn't working label Nov 9, 2025
@slachiewicz
slachiewicz merged commit 6d780b3 into master Nov 9, 2025
@slachiewicz
slachiewicz deleted the copilot/fix-zip-slip-vulnerability branch November 9, 2025 11:32
slachiewicz pushed a commit that referenced this pull request Nov 9, 2025
@slachiewicz
Fix Zip Slip vulnerability in archive extraction (#296)
ddf51d6
---------
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: slachiewicz <[email protected]>

(cherry picked from commit 6d780b3)
slachiewicz pushed a commit that referenced this pull request Nov 9, 2025
@slachiewicz
Fix Zip Slip vulnerability in archive extraction (#296)
36ea352
---------
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: slachiewicz <[email protected]>

(cherry picked from commit 6d780b3)
@cstamas

cstamas commented Mar 28, 2026

Copy link
Copy Markdown
Member

Can we have this backported to 3.x line as well?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@cstamas cstamas mentioned this pull request Mar 28, 2026
RAT-532: Bump org.codehaus.plexus:plexus-utils from 3.6.0 to 4.0.3 in /apache-rat-plugin apache/creadur-rat#641
Closed
@cstamas

cstamas commented Mar 28, 2026

Copy link
Copy Markdown
Member

NVM, missed it is already backported to 3.x

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@gsmet

gsmet commented Mar 30, 2026

Copy link
Copy Markdown

@cstamas it has been backported but I don't see a 3.x release so it's still an issue, right?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@cstamas

cstamas commented Mar 30, 2026

Copy link
Copy Markdown
Member

Right, 3.x branch has the fix, but 3.6.0 is last release, 3.6.1 yet to happen.

abelsromero reacted with confused emoji
All reactions
  • 😕 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@gsmet

gsmet commented Mar 31, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

@slachiewicz 👋 is there a plan for releasing a 3.x for Maven 3 consumption? Thanks!

headius reacted with heart emoji
All reactions
  • ❤️ 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@mashhurs mashhurs mentioned this pull request Apr 1, 2026
New release request jruby/ruby-maven-libs#7
Open
@headius

headius commented Apr 1, 2026

Copy link
Copy Markdown

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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@cstamas

cstamas commented Apr 1, 2026

Copy link
Copy Markdown
Member

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).

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@slawekjaranowski slawekjaranowski linked an issue Apr 2, 2026 that may be closed by this pull request
directory traversal still in org.codehaus.plexus.util.Expand #294
Closed
@gdfan777 gdfan777 mentioned this pull request Apr 4, 2026
Upgrade plexus-utils to 3.6.1+ / 4.0.3+ to fix critical Directory Traversal (CVE-2025-67030) gradle/gradle#37431
Closed
@Jenson3210 Jenson3210 mentioned this pull request Apr 8, 2026
Fix GHSA-6fmv-xxpf-w3cw: pin plexus-utils 3.6.1 and suppress false positive openrewrite/rewrite-maven-plugin#1138
Merged
2 tasks done
This was referenced May 29, 2026
Pin Gradle classpath plexus-utils to 4.0.3 to remediate CVE-2025-67030 navikt/sosialhjelp-kommune-service#72
Merged
Patch transitive plexus-utils to 4.0.3 to remediate GHSA-6fmv-xxpf-w3cw navikt/sosialhjelp-avtaler-api#393
Merged
@LEEKIYOON-SEC LEEKIYOON-SEC mentioned this pull request Jul 13, 2026
[Argus] CVE-2025-67030: plexus-utils의 Directory Traversal 취약점 LEEKIYOON-SEC/Argus-DEV#1120
Open
@Kanishk-Bansal Kanishk-Bansal mentioned this pull request Nov 16, 2026
fix(plexus-utils4): upgrade to 4.0.3 to address CVEs microsoft/azurelinux#20341
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@slachiewicz slachiewicz Awaiting requested review from slachiewicz

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@slachiewicz slachiewicz

Copilot code review Copilot

Labels

bug Something isn't working

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

directory traversal still in org.codehaus.plexus.util.Expand Fix code scanning alert - Arbitrary file write during archive extraction ("Zip Slip")

Uh oh!

There was an error while loading. Please reload this page.

5 participants

@cstamas @gsmet @headius @slachiewicz
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.