Skip to content

Commit

Permalink
Mitigating ZipSlip vulnerability (#6630)
Browse files Browse the repository at this point in the history
* patched org/nd4j/util/ArchiveUtils.java to mitigate ZipSlip vulnerability

* log nitpick
  • Loading branch information
conikeec authored and Adam Gibson committed Oct 24, 2018
1 parent 72ce4be commit f51f424
Showing 1 changed file with 8 additions and 0 deletions.
Expand Up @@ -65,7 +65,15 @@ public static void unzipFileTo(String file, String dest) throws IOException {

while (ze != null) {
String fileName = ze.getName();

String canonicalDestinationDirPath = new File(dest).getCanonicalPath();
File newFile = new File(dest + File.separator + fileName);
String canonicalDestinationFile = newFile.getCanonicalPath();

if (!canonicalDestinationFile.startsWith(canonicalDestinationDirPath + File.separator)) {
log.debug("Attempt to unzip entry is outside of the target dir");
throw new IOException("Entry is outside of the target dir: ");
}

if (ze.isDirectory()) {
newFile.mkdirs();
Expand Down

0 comments on commit f51f424

Please sign in to comment.