Skip to content

Commit

Permalink
Fix zipslip vulnerability (#3366)
Browse files Browse the repository at this point in the history
Thanks to The Snyk security team for bringing this up to our attention.
  • Loading branch information
yihanzhen authored and pongad committed Jun 11, 2018
1 parent ccfdd61 commit fad70bd
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -404,8 +404,13 @@ private Path downloadEmulator() throws IOException {
log.fine("Unzipping emulator");
}
ZipEntry entry = zipIn.getNextEntry();
while (entry != null) {
File filePath = new File(emulatorPath.toFile(), entry.getName());
while (entry != null) {
File filePath = new File(emulatorFolder, entry.getName());
String canonicalEmulatorFolderPath = emulatorFolder.getCanonicalPath();
String canonicalFilePath = filePath.getCanonicalPath();
if (!canonicalFilePath.startsWith(canonicalEmulatorFolderPath + File.separator)) {
throw new IllegalStateException("Entry is outside of the target dir: " + entry.getName());
}
if (!entry.isDirectory()) {
extractFile(zipIn, filePath);
} else {
Expand Down

0 comments on commit fad70bd

Please sign in to comment.