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

Bug-tracker: JLLeitschuh/security-research#18


Co-authored-by: Moderne <[email protected]>
  • Loading branch information
JLLeitschuh and TeamModerne committed Nov 18, 2022
1 parent bb53609 commit 0eaca11
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ private File readingPomFromJarFile()
{
base = base.substring( 0, base.lastIndexOf( '.' ) );
}
pomFile = File.createTempFile( base, ".pom" );
pomFile = Files.createTempFile( base, ".pom" ).toFile();

pomOutputStream = Files.newOutputStream( pomFile.toPath() );

Expand Down Expand Up @@ -498,7 +498,7 @@ private File generatePomFile()
Writer writer = null;
try
{
File pomFile = File.createTempFile( "mvninstall", ".pom" );
File pomFile = Files.createTempFile( "mvninstall", ".pom" ).toFile();

writer = new XmlStreamWriter( pomFile );
new MavenXpp3Writer().write( writer, model );
Expand Down

0 comments on commit 0eaca11

Please sign in to comment.