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 <Jonathan.Leitschuh@gmail.com>
Signed-off-by: Jonathan Leitschuh <Jonathan.Leitschuh@gmail.com>

Bug-tracker: JLLeitschuh/security-research#10

Co-authored-by: Moderne <team@moderne.io>
  • Loading branch information
JLLeitschuh and TeamModerne committed Jul 27, 2022
1 parent c191bb1 commit d3a300a
Showing 1 changed file with 2 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLConnection;
import java.nio.file.Files;

import junit.framework.TestCase;

Expand Down Expand Up @@ -95,11 +96,9 @@ public void testDirectoryListing() throws Exception
// TMPDIR/testDirectoryList39558
// TMPDIR/testDirectoryList39558/test.txt
// TMPDIR/testDirectoryList39558/test.dir
File rootDir = File.createTempFile("testDirectoryList", "");
File rootDir = Files.createTempDirectory("testDirectoryList").toFile();
try
{
rootDir.delete();
rootDir.mkdir();
System.out.println(rootDir);
File tmpFile = new File(rootDir, "test.txt");
tmpFile.createNewFile();
Expand Down

0 comments on commit d3a300a

Please sign in to comment.