Skip to content

Commit

Permalink
Merge pull request #1225 from kermitt2/alert-autofix-39
Browse files Browse the repository at this point in the history
Fix code scanning alert no. 39: Arbitrary file access during archive extraction ("Zip Slip")
  • Loading branch information
lfoppiano authored Jan 10, 2025
2 parents 2ab61a6 + 1c1df62 commit f6ac80f
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,10 @@ private static List<Path> unzip(InputStream is, File destinationDir) throws IOEx
ZipInputStream zipIn = new ZipInputStream(is);
ZipEntry entry = zipIn.getNextEntry();
while (entry != null) {
File filePath = new File(destinationDir, entry.getName());
File filePath = new File(destinationDir, entry.getName()).toPath().normalize().toFile();
if (!filePath.toPath().startsWith(destinationDir.toPath())) {
throw new IOException("Bad zip entry: " + entry.getName());
}
try {
if (!entry.isDirectory()) {
String absolutePath = filePath.getAbsolutePath();
Expand Down

0 comments on commit f6ac80f

Please sign in to comment.