From 9e47a2aa8e02795cfcb1ba2e0420f52cd1612874 Mon Sep 17 00:00:00 2001 From: Jonathan Leitschuh Date: Sat, 19 Nov 2022 02:04:08 +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/io/openmessaging/benchmark/worker/WorkerHandler.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/benchmark-framework/src/main/java/io/openmessaging/benchmark/worker/WorkerHandler.java b/benchmark-framework/src/main/java/io/openmessaging/benchmark/worker/WorkerHandler.java index 713e79f6..25359b22 100644 --- a/benchmark-framework/src/main/java/io/openmessaging/benchmark/worker/WorkerHandler.java +++ b/benchmark-framework/src/main/java/io/openmessaging/benchmark/worker/WorkerHandler.java @@ -21,6 +21,7 @@ import java.io.File; import java.net.HttpURLConnection; import java.nio.ByteBuffer; +import java.nio.file.Files; import java.util.List; import org.apache.bookkeeper.stats.StatsLogger; @@ -75,7 +76,7 @@ public WorkerHandler(Javalin app, StatsLogger statsLogger) { private void handleInitializeDriver(Context ctx) throws Exception { // Save config to temp file - File tempFile = File.createTempFile("driver-configuration" + System.currentTimeMillis(), "conf"); + File tempFile = Files.createTempFile("driver-configuration" + System.currentTimeMillis(), "conf").toFile(); Files.write(ctx.bodyAsBytes(), tempFile); localWorker.initializeDriver(tempFile);