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 <[email protected]>
Signed-off-by: Jonathan Leitschuh <[email protected]>

Bug-tracker: JLLeitschuh/security-research#10

Co-authored-by: Moderne <[email protected]>
  • Loading branch information
JLLeitschuh and TeamModerne committed Jul 27, 2022
1 parent 6c3cab0 commit 68c851e
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions src/main/java/tahrir/tools/TrUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import java.io.*;
import java.lang.reflect.Type;
import java.nio.file.Files;
import java.security.interfaces.RSAPrivateKey;
import java.security.interfaces.RSAPublicKey;
import java.util.Random;
Expand Down Expand Up @@ -162,13 +163,7 @@ public static BroadcastMessage getBroadcastMessageFrom(TrNode node, UserIdentity
public static File createTempDirectory() throws IOException {
final File temp;

temp = File.createTempFile("temp", Long.toString(System.nanoTime()));

if (!(temp.delete()))
throw new IOException("Could not delete temp file: " + temp.getAbsolutePath());

if (!(temp.mkdir()))
throw new IOException("Could not create temp directory: " + temp.getAbsolutePath());
temp = Files.createTempDirectory("temp" + Long.toString(System.nanoTime())).toFile();

return (temp);
}
Expand Down

0 comments on commit 68c851e

Please sign in to comment.