Skip to content

Commit

Permalink
vuln-fix: Temporary Directory Hijacking or Information Disclosure
Browse files Browse the repository at this point in the history
This fixes either Temporary Directory Hijacking, or Temporary Directory Local Information Disclosure.

Weakness: CWE-379: Creation of Temporary File in Directory with Insecure Permissions
Severity: High
CVSSS: 7.3
Detection: CodeQL & OpenRewrite (https://public.moderne.io/recipes/org.openrewrite.java.security.UseFilesCreateTempDirectory)

Reported-by: Jonathan Leitschuh <Jonathan.Leitschuh@gmail.com>
Signed-off-by: Jonathan Leitschuh <Jonathan.Leitschuh@gmail.com>

Bug-tracker: JLLeitschuh/security-research#10


Co-authored-by: Moderne <team@moderne.io>
  • Loading branch information
JLLeitschuh and TeamModerne committed Oct 4, 2022
1 parent ef67bf2 commit d4e8ce3
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions qulice-spi/src/main/java/com/qulice/spi/Environment.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import java.io.File;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
Expand Down Expand Up @@ -157,16 +158,7 @@ final class Mock implements Environment {
public Mock() throws IOException {
this.params = new HashMap<>();
this.classpath = new HashSet<>(1);
final File temp = File.createTempFile(
"mock", ".qulice",
new File(System.getProperty("java.io.tmpdir"))
);
if (!temp.delete()) {
throw new IllegalStateException("files collision");
}
if (!temp.mkdirs()) {
throw new IllegalStateException("mkdir failed");
}
final File temp = Files.createTempDirectory(new File(System.getProperty("java.io.tmpdir")).toPath(), "mock" + ".qulice").toFile();
FileUtils.forceDeleteOnExit(temp);
this.basedir = new File(temp, "basedir");
if (this.basedir.mkdirs()) {
Expand Down

0 comments on commit d4e8ce3

Please sign in to comment.