From 985706808f679d2102c764e3a07a3d83d8f466e1 Mon Sep 17 00:00:00 2001 From: Jonathan Leitschuh Date: Fri, 18 Nov 2022 22:59:25 +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 --- .../com/hpe/cloudfoundryjenkins/CloudFoundryPushPublisher.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/hpe/cloudfoundryjenkins/CloudFoundryPushPublisher.java b/src/main/java/com/hpe/cloudfoundryjenkins/CloudFoundryPushPublisher.java index f790bc6..ddc7ec0 100644 --- a/src/main/java/com/hpe/cloudfoundryjenkins/CloudFoundryPushPublisher.java +++ b/src/main/java/com/hpe/cloudfoundryjenkins/CloudFoundryPushPublisher.java @@ -41,6 +41,7 @@ import java.net.MalformedURLException; import java.net.URL; import java.net.UnknownHostException; +import java.nio.file.Files; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -398,7 +399,7 @@ private void pushAppBits(AbstractBuild build, BuildListener listener, Deployment if (appPath.isDirectory()) { // The build is distributed, and a directory // We need to make a copy of the target directory on the master - File tempAppFile = File.createTempFile("appFile", null); // This is on the master + File tempAppFile = Files.createTempFile("appFile", null).toFile(); // This is on the master OutputStream outputStream = new FileOutputStream(tempAppFile); appPath.zip(outputStream);