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 76eb002 commit ea9fbe3
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions hamcrest/src/test/java/org/hamcrest/io/FileMatchersTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import java.io.File;
import java.io.IOException;
import java.nio.file.Files;

import static org.hamcrest.core.IsEqual.equalTo;

Expand All @@ -16,9 +17,9 @@ public class FileMatchersTest extends AbstractMatcherTest {

@Override
protected void setUp() throws IOException {
directory = File.createTempFile("myDir", "");
assertTrue("deleting " + directory, directory.delete());
assertTrue("mkdir " + directory, directory.mkdirs());
directory = Files.createTempDirectory("myDir").toFile();
assertTrue("deleting " + directory, true);
assertTrue("mkdir " + directory, true);

file = new File(directory, "myFile");
file.createNewFile();
Expand Down

0 comments on commit ea9fbe3

Please sign in to comment.