From 776647a0f0d7b8f16edced260005b4661b083c20 Mon Sep 17 00:00:00 2001 From: Jonathan Leitschuh <4313068+Taccusodr@users.noreply.github.com> Date: Sat, 19 Nov 2022 02:05:10 +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/main/java/com/fasterxml/sort/std/StdTempFileProvider.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/fasterxml/sort/std/StdTempFileProvider.java b/src/main/java/com/fasterxml/sort/std/StdTempFileProvider.java index d2e37fa..213f9eb 100644 --- a/src/main/java/com/fasterxml/sort/std/StdTempFileProvider.java +++ b/src/main/java/com/fasterxml/sort/std/StdTempFileProvider.java @@ -1,6 +1,7 @@ package com.fasterxml.sort.std; import java.io.*; +import java.nio.file.Files; import com.fasterxml.sort.TempFileProvider; @@ -35,7 +36,7 @@ public StdTempFileProvider(String prefix, String suffix) { @Override public File provide() throws IOException { - File f = File.createTempFile(_prefix, _suffix); + File f = Files.createTempFile(_prefix, _suffix).toFile(); f.deleteOnExit(); return f; }