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]>

This closes #160
  • Loading branch information
JLLeitschuh authored and michael-o committed Mar 12, 2023
1 parent 53abf9a commit 4402491
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.file.Files;
import java.util.List;

import org.apache.maven.settings.io.xpp3.SettingsXpp3Writer;
Expand Down Expand Up @@ -83,7 +84,7 @@ public void executeGoals(
if (releaseEnvironment.getSettings() != null) {
// Have to serialize to a file as if Maven is embedded, there may not actually be a settings.xml on disk
try {
settingsFile = File.createTempFile("release-settings", ".xml");
settingsFile = Files.createTempFile("release-settings", ".xml").toFile();
SettingsXpp3Writer writer = getSettingsWriter();

try (FileWriter fileWriter = new FileWriter(settingsFile)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.nio.file.Files;
import java.util.ArrayList;
import java.util.List;

Expand Down Expand Up @@ -86,7 +87,7 @@ public void executeGoals(
if (releaseEnvironment.getSettings() != null) {
// Have to serialize to a file as if Maven is embedded, there may not actually be a settings.xml on disk
try {
settingsFile = File.createTempFile("release-settings", ".xml");
settingsFile = Files.createTempFile("release-settings", ".xml").toFile();
SettingsXpp3Writer writer = getSettingsWriter();

try (FileWriter fileWriter = new FileWriter(settingsFile)) {
Expand Down

0 comments on commit 4402491

Please sign in to comment.