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 38d0773 commit 07065cb
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/test/java/net/karneim/pojobuilder/testenv/Util.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@

import java.io.File;
import java.io.IOException;
import java.lang.reflect.UndeclaredThrowableException;
import java.lang.reflect.UndeclaredThrowableException;
import java.nio.file.Files;

public class Util {

public static File createTempDir() {
try {
File tempFile = File.createTempFile("temp", "project");
tempFile.delete();
tempFile.mkdir();
File tempFile = Files.createTempDirectory("temp" + "project").toFile();
if (!tempFile.exists()) {
throw new IllegalStateException(String.format("Directory '%s' could not be created.", tempFile));
}
Expand Down

0 comments on commit 07065cb

Please sign in to comment.