Skip to content

Commit

Permalink
vuln-fix: Temporary File Information Disclosure (#61)
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]>
Signed-off-by: Jonathan Leitschuh <[email protected]>

Bug-tracker: JLLeitschuh/security-research#18


Co-authored-by: Moderne <[email protected]>

Co-authored-by: Moderne <[email protected]>
  • Loading branch information
JLLeitschuh and TeamModerne authored Nov 23, 2022
1 parent 95656fd commit 7f82f49
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.io.File;
import java.io.IOException;
import java.nio.file.Files;

import com.github.davidmoten.util.Preconditions;

Expand Down Expand Up @@ -170,12 +171,12 @@ private static class FileFactoryHolder {
@Override
public File call() {
try {
return File.createTempFile(DEFAULT_FILE_PREFIX, "");
return Files.createTempFile(DEFAULT_FILE_PREFIX, "").toFile();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
};
}

}
}

0 comments on commit 7f82f49

Please sign in to comment.