Skip to content

Commit 188f3fb

Browse files
committed
Protect against malicious archives by validating destination. See https://githuib.com/ebresie/python4nb/issues/2
1 parent 226ca06 commit 188f3fb

File tree

1 file changed

+5
-0
lines changed
  • src/main/java/org/apache/netbeans/modules/python4nb/util

1 file changed

+5
-0
lines changed

src/main/java/org/apache/netbeans/modules/python4nb/util/FileUtils.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,11 @@ public static String decompressTarGz(File archive, File destination, boolean ski
382382
name = name.substring(archiveRootLength);
383383
}
384384
File destPath = new File(destination, name);
385+
/* Protect against malicious archives by validating destination.
386+
See https://githuib.com/ebresie/python4nb/issues/2 */
387+
if (!destPath.toPath().normalize().startsWith(destination.toPath())) {
388+
throw new IOException("Bad archive entry");
389+
}
385390
if (tarEntry.isDirectory()) {
386391
if (!destPath.isDirectory()
387392
&& !destPath.mkdirs()) {

0 commit comments

Comments
 (0)