From d1adb881b1c2ddaf499998db134e13b943cba94c Mon Sep 17 00:00:00 2001 From: Jonathan Leitschuh Date: Fri, 18 Nov 2022 22:47:47 +0000 Subject: [PATCH] vuln-fix: Temporary File Information Disclosure This fixes temporary file information disclosure vulnerability due to the use of the vulnerable `File.createTempFile()` method. The vulnerability is fixed by using the `Files.createTempFile()` method which sets the correct posix permissions. Weakness: CWE-377: Insecure Temporary File Severity: Medium CVSSS: 5.5 Detection: CodeQL & OpenRewrite (https://public.moderne.io/recipes/org.openrewrite.java.security.SecureTempFileCreation) Reported-by: Jonathan Leitschuh Signed-off-by: Jonathan Leitschuh Bug-tracker: https://github.com/JLLeitschuh/security-research/issues/18 Co-authored-by: Moderne --- .../astrazeneca/vardict/integrationtests/IntegrationTest.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/test/java/com/astrazeneca/vardict/integrationtests/IntegrationTest.java b/src/test/java/com/astrazeneca/vardict/integrationtests/IntegrationTest.java index 849d9c6..fff0fea 100644 --- a/src/test/java/com/astrazeneca/vardict/integrationtests/IntegrationTest.java +++ b/src/test/java/com/astrazeneca/vardict/integrationtests/IntegrationTest.java @@ -16,6 +16,7 @@ import org.testng.annotations.*; import java.io.*; +import java.nio.file.Files; import java.util.*; import static org.mockito.ArgumentMatchers.anyInt; @@ -153,7 +154,7 @@ private void runVarDict(String[] args) throws ParseException { } public static File makeBedFile(VarDictInput varDictInput) throws IOException { - File bed = File.createTempFile("tmpbed", ".bed"); + File bed = Files.createTempFile("tmpbed", ".bed").toFile(); bed.deleteOnExit(); try (FileWriter bedWriter = new FileWriter(bed)) {