This is an automated email from the ASF dual-hosted git repository.
dimuthuupe pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/airavata-mft.git
The following commit(s) were added to refs/heads/master by this push:
new 9d32413 vuln-fix: Temporary File Information Disclosure
9d32413 is described below
commit 9d32413fdb80b6f3c0dfb3d0f6b3038f55f435df
Author: Jonathan Leitschuh <[email protected]>
AuthorDate: Fri Nov 18 22:44:07 2022 +0000
vuln-fix: Temporary File Information Disclosure
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: https://github.com/JLLeitschuh/security-research/issues/18
Co-authored-by: Moderne <[email protected]>
---
.../org/apache/airavata/mft/transport/scp/SCPMetadataCollector.java | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git
a/transport/scp-transport/src/main/java/org/apache/airavata/mft/transport/scp/SCPMetadataCollector.java
b/transport/scp-transport/src/main/java/org/apache/airavata/mft/transport/scp/SCPMetadataCollector.java
index 47930fc..f6a7ba6 100644
---
a/transport/scp-transport/src/main/java/org/apache/airavata/mft/transport/scp/SCPMetadataCollector.java
+++
b/transport/scp-transport/src/main/java/org/apache/airavata/mft/transport/scp/SCPMetadataCollector.java
@@ -45,6 +45,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.*;
+import java.nio.file.Files;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
@@ -239,7 +240,7 @@ public class SCPMetadataCollector implements
MetadataCollector {
sshClient.addHostKeyVerifier((h, p, key) -> true);
- File privateKeyFile = File.createTempFile("id_rsa", "");
+ File privateKeyFile = Files.createTempFile("id_rsa", "").toFile();
BufferedWriter writer = new BufferedWriter(new
FileWriter(privateKeyFile));
writer.write(scpSecret.getPrivateKey());
writer.close();