Skip to content

Commit

Permalink
proper pathname limitation for zip entries
Browse files Browse the repository at this point in the history
fixing CWE-22
  • Loading branch information
haubi committed Mar 14, 2024
1 parent fcca85d commit 7a82f23
Showing 1 changed file with 2 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,8 @@ public void unzip(File zipFile, File destDir) throws IOException {
while (entries.hasMoreElements()) {
ZipEntry entry = entries.nextElement();
File realFile = new File(destDir, entry.getName());
if (!realFile.toPath().normalize().startsWith(destDir.toPath()))
throw new IOException("Bad zip entry");
if (entry.isDirectory()) {
FileUtils.mkdirs(realFile);
continue;
Expand Down

0 comments on commit 7a82f23

Please sign in to comment.