
GGrewal374990 (Community Member) asked a question.
I'm still getting the following flaw after implementing a method that checks the parameter -
This call to java.io.File() contains a path manipulation flaw. The argument to the function is a filename constructed using untrusted input. If an attacker is allowed to specify all or part of the filename, it may be possible to gain unauthorized access to files on the server, including those outside the webroot, that would be normally be inaccessible to end users. The level of exposure depends on the effectiveness of input validation routines, if any. The first argument to the constructor contains tainted data from the variable sanitiseFilePath(). The tainted data originated from an earlier call to java.lang.System.getProperty.
String sanitisedLogFilename = SecurityUtil.sanitiseFilePath(logFilename);
new File(sanitisedLogFilename).getParentFile().mkdirs();
I have the sanitiseFilePath() method annotated with @FilePathCleanser.
.png)
Hi @GGrewal374990 (Community Member),
an allow-list validation is a strong security control for CWE 73, and a remediation strategy that Veracode Static Analysis can automatically detect. However, for our static engine to detect it, the allow-list would have to apply in the way described here: https://community.veracode.com/s/article/Using-an-Allow-list-in-a-Way-Static-Analysis-can-Detect .
Thank you,
Florian Walter