Skip to content

Commit

Permalink
Codeql detects zipslip vulnerability (open-telemetry#8209)
Browse files Browse the repository at this point in the history
I think that the only way zipslip could happen is when name contains
`..` but codeql isn't able to cope with that. Removing the `..` check
gets rid of the code scanning alert.
  • Loading branch information
laurit authored Apr 4, 2023
1 parent b52bad1 commit e0ecb56
Showing 1 changed file with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,10 @@ private static void includeEmbeddedExtensionsIfFound(
File tempFile = new File(tempDirectory, name.substring(prefix.length()));
// reject extensions that would be extracted outside of temp directory
// https://security.snyk.io/research/zip-slip-vulnerability
if (name.indexOf("..") != -1
&& !tempFile
.getCanonicalFile()
.toPath()
.startsWith(tempDirectory.getCanonicalFile().toPath())) {
if (!tempFile
.getCanonicalFile()
.toPath()
.startsWith(tempDirectory.getCanonicalFile().toPath())) {
throw new IllegalStateException("Invalid extension " + name);
}
if (tempFile.createNewFile()) {
Expand Down

0 comments on commit e0ecb56

Please sign in to comment.