From 876fd2c0dbfbfc17212d776dfcde17cd05da6668 Mon Sep 17 00:00:00 2001 From: Jonathan Leitschuh Date: Fri, 18 Nov 2022 22:41:31 +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 --- .../java/org/apache/maven/shared/verifier/ForkedLauncher.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/apache/maven/shared/verifier/ForkedLauncher.java b/src/main/java/org/apache/maven/shared/verifier/ForkedLauncher.java index 54b2008..595243b 100644 --- a/src/main/java/org/apache/maven/shared/verifier/ForkedLauncher.java +++ b/src/main/java/org/apache/maven/shared/verifier/ForkedLauncher.java @@ -23,6 +23,7 @@ import java.io.FileWriter; import java.io.IOException; import java.io.Writer; +import java.nio.file.Files; import java.util.Collections; import java.util.Iterator; import java.util.List; @@ -169,7 +170,7 @@ public String getMavenVersion() File logFile; try { - logFile = File.createTempFile( "maven", "log" ); + logFile = Files.createTempFile( "maven", "log" ).toFile(); } catch ( IOException e ) {