From b823409b6347a1764b826998c501c80fe567ee78 Mon Sep 17 00:00:00 2001 From: Jonathan Leitschuh Date: Tue, 9 Aug 2022 03:21:56 +0000 Subject: [PATCH] vuln-fix: Temporary Directory Hijacking or Information Disclosure 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 Signed-off-by: Jonathan Leitschuh Bug-tracker: https://github.com/JLLeitschuh/security-research/issues/10 Co-authored-by: Moderne --- src/test/java/com/xebialabs/overthere/TemporaryFolder.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/test/java/com/xebialabs/overthere/TemporaryFolder.java b/src/test/java/com/xebialabs/overthere/TemporaryFolder.java index bdbdb1d8..b2d1e13e 100644 --- a/src/test/java/com/xebialabs/overthere/TemporaryFolder.java +++ b/src/test/java/com/xebialabs/overthere/TemporaryFolder.java @@ -24,15 +24,14 @@ import java.io.File; import java.io.IOException; +import java.nio.file.Files; public class TemporaryFolder { private File tempRoot; public void create() throws IOException { - tempRoot = File.createTempFile("testng", ".tmp"); - tempRoot.delete(); - tempRoot.mkdir(); + tempRoot = Files.createTempDirectory("testng" + ".tmp").toFile(); } public void delete() {