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 9506234 commit aa7ac34
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

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

import org.apache.maven.model.Model;
Expand Down Expand Up @@ -59,7 +60,7 @@ public void resolveScmConnectionByParent()
Model parentModel = mock( Model.class );
when( parentModel.getModules() ).thenReturn( Collections.singletonList( "module" ) );
when( parent.getModel() ).thenReturn( parentModel );
File parentBasedir = File.createTempFile( "tmpBasedir", null );
File parentBasedir = Files.createTempFile( "tmpBasedir", null ).toFile();
when( parent.getBasedir() ).thenReturn( parentBasedir );

MavenProject project = mock( MavenProject.class );
Expand All @@ -85,7 +86,7 @@ public void resolveScmDeveloperConnectionByParent()
Model parentModel = mock( Model.class );
when( parentModel.getModules() ).thenReturn( Collections.singletonList( "module" ) );
when( parent.getModel() ).thenReturn( parentModel );
File parentBasedir = File.createTempFile( "tmpBasedir", null );
File parentBasedir = Files.createTempFile( "tmpBasedir", null ).toFile();
when( parent.getBasedir() ).thenReturn( parentBasedir );

MavenProject project = mock( MavenProject.class );
Expand Down

0 comments on commit aa7ac34

Please sign in to comment.