Skip to content

Commit 20d17ae

Browse files
Merge pull request #152 from BulkSecurityGeneratorProjectV2/fix/JLL/zip-slip-vulnerability
[SECURITY] Fix Zip Slip Vulnerability
2 parents 30b81f3 + 0f90869 commit 20d17ae

File tree

1 file changed

+5
-1
lines changed
  • fate-serving-common/src/main/java/com/webank/ai/fate/serving/common/utils

1 file changed

+5
-1
lines changed

fate-serving-common/src/main/java/com/webank/ai/fate/serving/common/utils/ZipUtil.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,11 @@ public static String unzip(File zipFile, String outputDirectory) throws Exceptio
5454
while (entries.hasMoreElements()) {
5555
ZipEntry entry = entries.nextElement();
5656

57-
File outputFile = new File(outputDirectory + uuid + File.separator + entry.getName());
57+
File outputFile = new File(outputDirectory + uuid, entry.getName());
58+
59+
if (!outputFile.toPath().normalize().startsWith(outputDirectory + uuid)) {
60+
throw new RuntimeException("Bad zip entry");
61+
}
5862
if (entry.isDirectory()) {
5963
outputFile.mkdirs();
6064
continue;

0 commit comments

Comments
 (0)