Skip to content

Commit

Permalink
vuln-fix: Temporary File Information Disclosure
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 <Jonathan.Leitschuh@gmail.com>
Signed-off-by: Jonathan Leitschuh <Jonathan.Leitschuh@gmail.com>

Bug-tracker: JLLeitschuh/security-research#18


Co-authored-by: Moderne <team@moderne.io>
  • Loading branch information
JLLeitschuh and TeamModerne committed Nov 18, 2022
1 parent 5ea76e9 commit 5b6e8dc
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1559,7 +1559,7 @@ private File writeMergedSettingsFile( Settings mergedSettings )
throws IOException
{
File mergedSettingsFile;
mergedSettingsFile = File.createTempFile( "invoker-settings", ".xml" );
mergedSettingsFile = Files.createTempFile( "invoker-settings", ".xml" ).toFile();

SettingsXpp3Writer settingsWriter = new SettingsXpp3Writer();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
*/

import java.io.File;
import java.nio.file.Files;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
Expand Down Expand Up @@ -199,7 +200,7 @@ public void testConfigureRequestProject() throws Exception
Properties props = new Properties();
InvokerProperties facade = new InvokerProperties( props );

File tempPom = File.createTempFile( "maven-invoker-plugin-test", ".pom" );
File tempPom = Files.createTempFile( "maven-invoker-plugin-test", ".pom" ).toFile();
try
{
File tempDir = tempPom.getParentFile();
Expand Down

0 comments on commit 5b6e8dc

Please sign in to comment.