From 1ff3178192ff488453668b4257d6392cbf19bf4b Mon Sep 17 00:00:00 2001 From: Jonathan Leitschuh Date: Fri, 25 Nov 2022 01:02:09 -0500 Subject: [PATCH] vuln-fix: Temporary File Information Disclosure (#210) 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 --- .../src/test/java/org/apache/camel/blueprint/MainTest.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/components/camel-blueprint-main/src/test/java/org/apache/camel/blueprint/MainTest.java b/components/camel-blueprint-main/src/test/java/org/apache/camel/blueprint/MainTest.java index fd045a3cd..c3876cbbb 100644 --- a/components/camel-blueprint-main/src/test/java/org/apache/camel/blueprint/MainTest.java +++ b/components/camel-blueprint-main/src/test/java/org/apache/camel/blueprint/MainTest.java @@ -20,6 +20,7 @@ import java.io.FileOutputStream; import java.net.URL; import java.net.URLClassLoader; +import java.nio.file.Files; import org.apache.aries.util.io.IOUtils; import org.apache.camel.ProducerTemplate; @@ -64,7 +65,7 @@ public void testMainWithoutIncludingTestBundle() throws Exception { .set("Bundle-ManifestVersion", "2") .set("Bundle-SymbolicName", SYMBOLIC_NAME) .set("Bundle-Version", "1.0.0"); - File tb = File.createTempFile(SYMBOLIC_NAME + "-", ".jar", new File("target")); + File tb = Files.createTempFile(new File("target").toPath(), SYMBOLIC_NAME + "-", ".jar").toFile(); FileOutputStream out = new FileOutputStream(tb); IOUtils.copy(bundle.build(), out); out.close();