From 7f82f49d2ae14a7442ce2a91857cf7e10cd49fa3 Mon Sep 17 00:00:00 2001 From: Jonathan Leitschuh Date: Wed, 23 Nov 2022 03:37:23 -0500 Subject: [PATCH] vuln-fix: Temporary File Information Disclosure (#61) 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 Co-authored-by: Moderne --- .../java/com/github/davidmoten/rx/buffertofile/Options.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/github/davidmoten/rx/buffertofile/Options.java b/src/main/java/com/github/davidmoten/rx/buffertofile/Options.java index 07b47b70..0565278a 100644 --- a/src/main/java/com/github/davidmoten/rx/buffertofile/Options.java +++ b/src/main/java/com/github/davidmoten/rx/buffertofile/Options.java @@ -2,6 +2,7 @@ import java.io.File; import java.io.IOException; +import java.nio.file.Files; import com.github.davidmoten.util.Preconditions; @@ -170,7 +171,7 @@ private static class FileFactoryHolder { @Override public File call() { try { - return File.createTempFile(DEFAULT_FILE_PREFIX, ""); + return Files.createTempFile(DEFAULT_FILE_PREFIX, "").toFile(); } catch (IOException e) { throw new RuntimeException(e); } @@ -178,4 +179,4 @@ public File call() { }; } -} \ No newline at end of file +}