Skip to content

Commit

Permalink
Fix zip slip issue on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
nbaars committed May 24, 2021
1 parent ac542ad commit 1381daf
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,10 @@ public void assignment4() throws IOException {
}

public void assignment5() throws IOException {
var webGoatDirectory = new File(System.getProperty("user.dir") + "/target/.webgoat/PathTraversal/" + getWebgoatUser());
var webGoatHome = System.getProperty("user.dir") + "/target/.webgoat/PathTraversal/" + getWebgoatUser();
webGoatHome = webGoatHome.replaceAll("^[a-zA-Z]:", ""); //Remove C: from the home directory on Windows

var webGoatDirectory = new File(webGoatHome);
var zipFile = new File(webGoatDirectory, "upload.zip");
try (var zos = new ZipOutputStream(new FileOutputStream(zipFile))) {
ZipEntry e = new ZipEntry("../../../../../../../../../../" + webGoatDirectory.toString() + "/image.jpg");
Expand Down

0 comments on commit 1381daf

Please sign in to comment.