Skip to content

Commit

Permalink
Fix code scanning alert no. 7: Arbitrary file access during archive e…
Browse files Browse the repository at this point in the history
…xtraction ("Zip Slip")

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
  • Loading branch information
hazendaz and github-advanced-security[bot] authored Sep 26, 2024
1 parent 7194767 commit ec07133
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/main/java/org/apache/ibatis/io/DefaultVFS.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,15 @@ public List<String> list(URL url, String path) throws IOException {
if (log.isDebugEnabled()) {
log.debug("Listing " + url);
}
File destinationDir = new File(path);
for (JarEntry entry; (entry = jarInput.getNextJarEntry()) != null;) {
if (log.isDebugEnabled()) {
log.debug("Jar entry: " + entry.getName());
}
File entryFile = new File(destinationDir, entry.getName()).getCanonicalFile();
if (!entryFile.getPath().startsWith(destinationDir.getCanonicalPath())) {
throw new IOException("Bad zip entry: " + entry.getName());
}
children.add(entry.getName());
}
}
Expand Down

0 comments on commit ec07133

Please sign in to comment.