Skip to content

Commit

Permalink
vuln-fix: Temporary File Information Disclosure (#210)
Browse files Browse the repository at this point in the history
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 <Jonathan.Leitschuh@gmail.com>
Signed-off-by: Jonathan Leitschuh <Jonathan.Leitschuh@gmail.com>

Bug-tracker: JLLeitschuh/security-research#18


Co-authored-by: Moderne <team@moderne.io>

Co-authored-by: Moderne <team@moderne.io>
  • Loading branch information
2 people authored and davsclaus committed Nov 25, 2022
1 parent 30aafd2 commit 1ff3178
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 1ff3178

Please # to comment.