Skip to content

Commit

Permalink
[tests] 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]>
Co-authored-by: Violeta Georgieva <[email protected]>
  • Loading branch information
3 people committed Jul 28, 2022
1 parent 13d6c98 commit f632dd0
Showing 1 changed file with 2 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017-2021 VMware, Inc. or its affiliates, All Rights Reserved.
* Copyright (c) 2017-2022 VMware, Inc. or its affiliates, All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -139,9 +139,7 @@ void testFromPath() throws Exception {

private static File createTemporaryDirectory() {
try {
final File tempDir = File.createTempFile("ByteBufFluxTest", "", null);
assertThat(tempDir.delete()).isTrue();
assertThat(tempDir.mkdir()).isTrue();
final File tempDir = Files.createTempDirectory("ByteBufFluxTest").toFile();
return tempDir;
}
catch (Exception e) {
Expand Down

0 comments on commit f632dd0

Please sign in to comment.