Skip to content

Commit 5457171

Browse files
committed
Fixing potential Zip Slip Vulnerability, see https://snyk.io/research/zip-slip-vulnerability
1 parent 205ac91 commit 5457171

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

  • java/client/src/org/openqa/selenium/io

java/client/src/org/openqa/selenium/io/Zip.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,12 @@ public static void unzip(InputStream source, File outputDir) throws IOException
110110
}
111111

112112
public static void unzipFile(File output, InputStream zipStream, String name) throws IOException {
113+
String canonicalDestinationDirPath = output.getCanonicalPath();
113114
File toWrite = new File(output, name);
115+
String canonicalDestinationFile = toWrite.getCanonicalPath();
116+
if (!canonicalDestinationFile.startsWith(canonicalDestinationDirPath + File.separator)) {
117+
throw new IOException("Entry is outside of the target dir: " + name);
118+
}
114119

115120
if (!FileHandler.createDir(toWrite.getParentFile()))
116121
throw new IOException("Cannot create parent directory for: " + name);

0 commit comments

Comments
 (0)