From 2b12e106a669cdb9bdb8b9c6046dfcaaa6858143 Mon Sep 17 00:00:00 2001 From: Jonathan Leitschuh Date: Fri, 18 Nov 2022 22:59:58 +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 --- .../src/test/java/com/cloudera/cli/validator/MainTest.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/validator/src/test/java/com/cloudera/cli/validator/MainTest.java b/validator/src/test/java/com/cloudera/cli/validator/MainTest.java index 698be6f..95b78f6 100644 --- a/validator/src/test/java/com/cloudera/cli/validator/MainTest.java +++ b/validator/src/test/java/com/cloudera/cli/validator/MainTest.java @@ -19,6 +19,7 @@ import java.io.File; import java.io.FileWriter; import java.io.IOException; +import java.nio.file.Files; import org.junit.Before; import org.junit.Test; @@ -92,7 +93,7 @@ public void testBadSdlWithExtraServiceTypeFile() throws IOException { FileWriter fileOutput = null; File tempFile = null; try { - tempFile = File.createTempFile("dependencySdl",".txt"); + tempFile = Files.createTempFile("dependencySdl", ".txt").toFile(); fileOutput = new FileWriter(tempFile); fileOutput.write("SPARK" + "\n"); fileOutput.write("FOO" + "\n");