From 52be8fafda3abee7404548f17fca6e1b7877fe41 Mon Sep 17 00:00:00 2001 From: Jonathan Leitschuh Date: Mon, 13 Feb 2023 05:28:27 -0500 Subject: [PATCH] [MPLUGIN-453] Fix Temporary File Information Disclosure (#176) 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 Bug-tracker: https://github.com/JLLeitschuh/security-research/issues/18 Co-authored-by: Moderne Co-authored-by: Guillaume Nodet --- .../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 26eb6c29..55dfc8ee 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 @@ -26,6 +26,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; @@ -140,7 +141,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();