Skip to content

directory traversal still in org.codehaus.plexus.util.Expand #294

Closed

Description

@Crispy-fried-chicken

Hi, we have detected a directory traversal vulnerability in the function extractFile in the class org.codehaus.plexus.util.Expand, The target function extractFile uses FileUtils.resolveFile(dir, entryName) to resolve the file path, where entryName is from an archive entry (external input). It then checks if the resolved file's absolute path starts with the target directory's absolute path using f.getAbsolutePath().startsWith(dir.getAbsolutePath()). This check is insufficient for preventing path traversal because it relies on string prefix matching, which can be bypassed if the resolved path uses different canonical forms (e.g., symlinks, case differences, or redundant path elements). Additionally, resolveFile normalizes the path but does not ensure it remains under the base directory; the check in extractFile is the primary defense. However, this check is vulnerable to partial matches (e.g., if dir is /tmp/app and an attacker uses entryName like ../app/../etc/passwd, the resolved path might be /etc/passwd, which does not start with /tmp/app—so it would be blocked—but if the attacker uses a path that shares a prefix, it might bypass). The code does not use canonicalization before the check, which is critical. The resolveFile function handles path separators and uses getCanonicalFile(), but the check in extractFile uses getAbsolutePath(), which may not be canonical.
This could allow bypasses via symlinks or other tricks. Overall, the check is prone to false negatives due to the lack of canonical path comparison.

Activity

  1. wleese commented on Mar 31, 2026

    @wleese

    Will 3.6.1 be released to fix this issue?

  2. toby1984 commented on Apr 10, 2026

    @toby1984

    Just as a side note, this rabbit hole goes deep - a plethora of Maven plugins are using vulnerable versions of plexus-utils (not saying those are actually using the impacted code path though) and will all need to do a new release.

    One of our projects (~50 Maven modules, 600 kloc) shows the following dependencies (gathered by massaging "mvn dependency:resolve-plugins" output, build using Apache Maven 3.9.14):

    org.apache.maven.plugins:maven-surefire-plugin:maven-plugin:3.1.2:runtime -> plexus-utils:3.5.0
    org.apache.maven.plugins:maven-install-plugin:maven-plugin:3.1.1:runtime -> plexus-utils:3.5.0
    org.apache.maven.plugins:maven-war-plugin:maven-plugin:3.4.0:runtime -> plexus-utils:3.5.1
    org.apache.maven.plugins:maven-site-plugin:maven-plugin:4.0.0-M10:runtime -> plexus-utils:3.5.1
    org.apache.maven.plugins:maven-jar-plugin:maven-plugin:3.3.0:runtime -> plexus-utils:3.4.2
    org.apache.maven.plugins:maven-enforcer-plugin:maven-plugin:3.4.1:runtime -> plexus-utils:3.5.1
    org.apache.maven.plugins:maven-clean-plugin:maven-plugin:3.3.1:runtime -> plexus-utils:4.0.0
    org.apache.maven.plugins:maven-deploy-plugin:maven-plugin:3.1.1:runtime -> plexus-utils:3.5.0
    org.apache.maven.plugins:maven-compiler-plugin:maven-plugin:3.11.0:runtime -> plexus-utils:3.5.0
    org.apache.maven.plugins:maven-resources-plugin:maven-plugin:3.3.1:runtime -> plexus-utils:3.5.1
    org.apache.maven.plugins:maven-dependency-plugin:maven-plugin:3.6.0:runtime -> plexus-utils:3.5.1
    org.codehaus.mojo:jaxws-maven-plugin:maven-plugin:2.6:runtime -> plexus-utils:3.2.1
    org.jvnet.jaxb2.maven2:maven-jaxb2-plugin:maven-plugin:0.13.3:runtime -> plexus-utils:1.5.15
    com.alexnederlof:jasperreports-plugin:maven-plugin:2.8:runtime -> plexus-utils:3.2.1
    org.codehaus.mojo:buildnumber-maven-plugin:maven-plugin:3.2.0:runtime -> plexus-utils:3.5.1
    org.apache.maven.plugins:maven-assembly-plugin:maven-plugin:3.6.0:runtime -> plexus-utils:3.5.1

    Even after upgrading/pinning all of those plugins to their latest releases (using in our pom.xml) they still only depend on vulnerable version.

  3. slawekjaranowski commented on Apr 10, 2026

    @slawekjaranowski
    Member

    @toby1984 thanks, should be reported plugin by plugin .... after check in not updated ....

    I will try to release Apache Maven plugins ... in this month

  4. toby1984 commented on Apr 14, 2026

    @toby1984

    Thank you ! FWIW, I ran a very crude check (just grep for imports of org.codehaus.plexus.util.Expand) across a limited set of Maven core plugins (the ones our product is using during build time) and could find NO usages.

    These are the GIT tags and plugins I checked:

    GIT tag Plugin
    surefire-3.1.2 maven-surefire
    maven-install-plugin-3.1.1 maven-install-plugin
    maven-war-plugin-3.4.0 maven-war-plugin
    maven-site-plugin-4.0.0-M10 maven-site-plugin
    maven-jar-plugin-3.3.0 maven-jar-plugin
    enforcer-3.4.1 maven-enforcer
    maven-clean-plugin-3.3.1 maven-clean-plugin
    maven-deploy-plugin-3.1.1 maven-deploy-plugin
    maven-compiler-plugin-3.11.0 maven-compiler-plugin
    maven-resources-plugin-3.3.1 maven-resources-plugin
    maven-dependency-plugin-3.6.0 maven-dependency-plugin
    jaxws-maven-plugin-2.6 jaxws-maven-plugin
    0.13.3 maven-jaxb2-plugin
    jasperreports-plugin-2.8 Jasper-report-maven-plugin
    buildnumber-maven-plugin-3.2.0 buildnumber-maven-plugin
    maven-assembly-plugin-3.6.0 maven-assembly-plugin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions