Skip to content

Commit

Permalink
vuln-fix: Temporary File Information Disclosure (#60)
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 <[email protected]>

Bug-tracker: JLLeitschuh/security-research#18

Co-authored-by: Moderne <[email protected]>
  • Loading branch information
JLLeitschuh and TeamModerne authored Mar 15, 2023
1 parent 34fef47 commit 2dd9fb6
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ static OutputStream createOutputStream(File file) throws IOException {
}

static File createTempFile(String prefix, String suffix) throws IOException {
File file = File.createTempFile(prefix + "-", "." + suffix);
File file = Files.createTempFile(prefix + "-", "." + suffix).toFile();
// always delete on exit but try to delete sooner...
file.deleteOnExit();

Expand Down

0 comments on commit 2dd9fb6

Please sign in to comment.