The application creates temporary withouth properly restricting their privileges or access modes, allowing an attacker to craft new attack vectors
- Get access to the created temporary files.
- Tamper data contained in the created temporary files.
Create the temporary files in a different directory than the default provided by the Operative system and ensure it has 0600 permission mask.
Authenticated attacker with local access to the server.
⌚ 60 minutes.
Default score using CVSS 3.1. It may change depending on the context of the src.
Default score using CVSS 4.0. It may change depending on the context of the src.
This java method
has the following signature:
public static File createTempFile(
// The prefix string defines the files name;
// must be at least three characters long
String prefix,
// The suffix string defines the file's extension;
// if null the suffix ".tmp" will be used
String suffix,
// The directory in which the file is to be created.
// For default temporary-file directory null is to passed.
File directory,
)
ls
command,
but nothing impedes the attacker
from executing
cat directory/file
.File.createTempFile()
a file.java.io.File.createTempFile
method
creates files with write permissions
in groups and other:
import java.io.File;
public class Test {
public static void main(String[] args){
try {
System.out.println(File.createTempFile("xxx", null));
}
catch (Exception e) {}
}
}
/*
* $ ls -al $(javac Test.java && java Test)
*
* -rw-r--r-
- 1 fluid fluid 0 Aug 28 14:44 /tmp/xxx948760279845756007.tmp
*/
java.nio.file.Files.createTempFile
.attrs
argument
(an optional list of file attributes
to set atomically when creating the file).