|
| 1 | +Description: Fix CVE-2025-67030: Directory Traversal vulnerability |
| 2 | + Fix Zip Slip vulnerability in archive extraction by using getCanonicalPath() |
| 3 | + instead of getAbsolutePath() for path validation. |
| 4 | +Author: Copilot <198982749+Copilot@users.noreply.github.com> |
| 5 | +Origin: upstream, https://github.com/codehaus-plexus/plexus-utils/commit/36ea3526309d2842075bf018d45152816a37fc98 |
| 6 | +Bug: https://security-tracker.debian.org/tracker/CVE-2025-67030 |
| 7 | +Forwarded: not-needed |
| 8 | + |
| 9 | +Index: github-plexus-utils2-67030/src/main/java/org/codehaus/plexus/util/Expand.java |
| 10 | +=================================================================== |
| 11 | +--- github-plexus-utils2-67030.orig/src/main/java/org/codehaus/plexus/util/Expand.java |
| 12 | ++++ github-plexus-utils2-67030/src/main/java/org/codehaus/plexus/util/Expand.java |
| 13 | +@@ -116,9 +116,23 @@ public class Expand |
| 14 | + { |
| 15 | + File f = FileUtils.resolveFile( dir, entryName ); |
| 16 | + |
| 17 | +- if ( !f.getAbsolutePath().startsWith( dir.getAbsolutePath() ) ) |
| 18 | ++ try |
| 19 | ++ { |
| 20 | ++ String canonicalDirPath = dir.getCanonicalPath(); |
| 21 | ++ String canonicalFilePath = f.getCanonicalPath(); |
| 22 | ++ |
| 23 | ++ // Ensure the file is within the target directory |
| 24 | ++ // We need to check that the canonical file path starts with the canonical directory path |
| 25 | ++ // followed by a file separator to prevent path traversal attacks |
| 26 | ++ if ( !canonicalFilePath.startsWith( canonicalDirPath + File.separator ) |
| 27 | ++ && !canonicalFilePath.equals( canonicalDirPath ) ) |
| 28 | ++ { |
| 29 | ++ throw new IOException( "Entry '" + entryName + "' outside the target directory." ); |
| 30 | ++ } |
| 31 | ++ } |
| 32 | ++ catch ( IOException e ) |
| 33 | + { |
| 34 | +- throw new IOException( "Entry '" + entryName + "' outside the target directory." ); |
| 35 | ++ throw new IOException( "Failed to verify entry path for '" + entryName + "'", e ); |
| 36 | + } |
| 37 | + |
| 38 | + try |
0 commit comments