From 432481d3800ce0b0978a706594a16a17e821c98a Mon Sep 17 00:00:00 2001 From: Jonathan Leitschuh Date: Fri, 18 Nov 2022 22:41:04 +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/script/ant/AntMojoWrapperTest.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/maven-script/maven-script-ant/src/test/java/org/apache/maven/script/ant/AntMojoWrapperTest.java b/maven-script/maven-script-ant/src/test/java/org/apache/maven/script/ant/AntMojoWrapperTest.java index 7c1a014af..913251fc5 100644 --- a/maven-script/maven-script-ant/src/test/java/org/apache/maven/script/ant/AntMojoWrapperTest.java +++ b/maven-script/maven-script-ant/src/test/java/org/apache/maven/script/ant/AntMojoWrapperTest.java @@ -37,6 +37,7 @@ import java.io.Reader; import java.net.URISyntaxException; import java.net.URL; +import java.nio.file.Files; import java.nio.file.Paths; import java.util.ArrayList; import java.util.Collections; @@ -145,7 +146,7 @@ private List run( String pluginXml ) File pluginXmlFile = Paths.get( resource.toURI() ).toFile(); - File jarFile = File.createTempFile( "AntMojoWrapperTest.", ".test.jar" ); + File jarFile = Files.createTempFile( "AntMojoWrapperTest.", ".test.jar" ).toFile(); jarFile.deleteOnExit(); JarArchiver archiver = new JarArchiver();