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
2 people authored and michael-o committed Apr 18, 2023
1 parent 7efb92f commit ff1e8a5
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import java.io.IOException;
import java.io.OutputStream;
import java.io.Reader;
import java.nio.file.Files;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
Expand Down Expand Up @@ -855,7 +856,7 @@ else if ( "plain".equals( outputFileFormat ) )
{
// Write a plain output file to the standard output file,
// and write an XML output file to the temp directory that can be used to count violations
outputXmlFile = File.createTempFile( "checkstyle-result", ".xml" );
outputXmlFile = Files.createTempFile( "checkstyle-result", ".xml" ).toFile();
outputXmlFile.deleteOnExit();
OutputStream xmlOut = getOutputStream( outputXmlFile );
CompositeAuditListener compoundListener = new CompositeAuditListener();
Expand Down

0 comments on commit ff1e8a5

Please sign in to comment.