Skip to content

Commit

Permalink
vuln-fix: Temporary Directory Hijacking or Information Disclosure
Browse files Browse the repository at this point in the history
This fixes either Temporary Directory Hijacking, or Temporary Directory Local Information Disclosure.

Weakness: CWE-379: Creation of Temporary File in Directory with Insecure Permissions
Severity: High
CVSSS: 7.3
Detection: CodeQL & OpenRewrite (https://public.moderne.io/recipes/org.openrewrite.java.security.UseFilesCreateTempDirectory)

Reported-by: Jonathan Leitschuh <[email protected]>
Signed-off-by: Jonathan Leitschuh <[email protected]>

Bug-tracker: JLLeitschuh/security-research#10


Co-authored-by: Moderne <[email protected]>
  • Loading branch information
JLLeitschuh and TeamModerne committed Oct 4, 2022
1 parent d4c2ce1 commit bbaa5b6
Showing 1 changed file with 2 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import javax.activation.DataSource;
import java.io.File;
import java.io.InputStream;
import java.nio.file.Files;


/** Test the PartOnFile class */
Expand Down Expand Up @@ -114,15 +115,7 @@ public void testGetAllheaders() throws Exception {
}

private void createTemporaryDirectory() throws Exception {
temp = File.createTempFile("partOnFileTest", ".tmp");

if (!temp.delete()) {
fail("Cannot delete from temporary directory. File: " + temp.toURL());
}

if (!temp.mkdir()) {
fail("Cannot create a temporary location for part files");
}
temp = Files.createTempDirectory("partOnFileTest" + ".tmp").toFile();
}

private void deleteTemporaryDirectory() throws Exception {
Expand Down

0 comments on commit bbaa5b6

Please sign in to comment.