Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SECURITY] Fix Temporary File Information Disclosure Vulnerability #792

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/main/java/hudson/plugins/ec2/ssh/EC2MacLauncher.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
import java.net.InetSocketAddress;
import java.net.Proxy;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.util.logging.Level;
import java.util.logging.Logger;

Expand Down Expand Up @@ -294,7 +295,7 @@ private File createIdentityKeyFile(EC2Computer computer) throws IOException {
privateKey = ec2PrivateKey.getPrivateKey();
}

File tempFile = File.createTempFile("ec2_", ".pem");
File tempFile = Files.createTempFile("ec2_", ".pem").toFile();

try {
FileOutputStream fileOutputStream = new FileOutputStream(tempFile);
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/hudson/plugins/ec2/ssh/EC2UnixLauncher.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
import java.net.InetSocketAddress;
import java.net.Proxy;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.util.Base64;
import java.util.logging.Level;
import java.util.logging.Logger;
Expand Down Expand Up @@ -316,7 +317,7 @@ private File createIdentityKeyFile(EC2Computer computer) throws IOException {
privateKey = ec2PrivateKey.getPrivateKey();
}

File tempFile = File.createTempFile("ec2_", ".pem");
File tempFile = Files.createTempFile("ec2_", ".pem").toFile();

try {
FileOutputStream fileOutputStream = new FileOutputStream(tempFile);
Expand Down Expand Up @@ -344,7 +345,7 @@ private File createHostKeyFile(EC2Computer computer, String ec2HostAddress, Task
if (ec2HostKey == null){
return null;
}
File tempFile = File.createTempFile("ec2_", "_known_hosts");
File tempFile = Files.createTempFile("ec2_", "_known_hosts").toFile();
String knownHost = "";
knownHost = String.format("%s %s %s", ec2HostAddress, ec2HostKey.getAlgorithm(), Base64.getEncoder().encodeToString(ec2HostKey.getKey()));

Expand Down