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 523b7cd commit 47d889c
Showing 1 changed file with 2 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

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

import org.jboss.as.controller.services.path.PathManagerService;
import org.junit.After;
Expand Down Expand Up @@ -73,10 +74,7 @@ private void initializeHandler(boolean rotateAtStartup) {

private static File createTempDir() {
try {
File tempFile = File.createTempFile("test-config", "");
if (!tempFile.delete() || !tempFile.mkdir()) {
throw new IOException("Couldn't create temp directory.");
}
File tempFile = Files.createTempDirectory("test-config").toFile();
return tempFile;
} catch (Exception e) {
throw new RuntimeException("Couldn't create temp directory.", e);
Expand Down

0 comments on commit 47d889c

Please sign in to comment.