From befadc8534310e3868d6dd4f3663c8ae0ae68fff Mon Sep 17 00:00:00 2001 From: Jonathan Leitschuh Date: Fri, 18 Nov 2022 23:00:20 +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 --- .../symbolsolver/resolution/typesolvers/JarTypeSolver.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/javaparser-symbol-solver-core/src/main/java/com/github/javaparser/symbolsolver/resolution/typesolvers/JarTypeSolver.java b/javaparser-symbol-solver-core/src/main/java/com/github/javaparser/symbolsolver/resolution/typesolvers/JarTypeSolver.java index b8b4c2e7e..344b297e7 100644 --- a/javaparser-symbol-solver-core/src/main/java/com/github/javaparser/symbolsolver/resolution/typesolvers/JarTypeSolver.java +++ b/javaparser-symbol-solver-core/src/main/java/com/github/javaparser/symbolsolver/resolution/typesolvers/JarTypeSolver.java @@ -35,6 +35,7 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; +import java.nio.file.Files; import java.nio.file.Path; import java.util.Enumeration; import java.util.HashMap; @@ -164,7 +165,7 @@ public JarTypeSolver(InputStream jarInputStream) throws IOException { * @throws IOException If an I/O exception occurs while creating the temporary file. */ private File dumpToTempFile(InputStream inputStream) throws IOException { - File tempFile = File.createTempFile("jar_file_from_input_stream", ".jar"); + File tempFile = Files.createTempFile("jar_file_from_input_stream", ".jar").toFile(); tempFile.deleteOnExit(); byte[] buffer = new byte[8 * 1024];