GGrewal374990 (Community Member) asked a question.

Unable to fix CWE-73 after implementing a whitelisting method

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.

 


Topics (1)

No articles found
Loading

Ask the Community

Get answers, share a use case, discuss your favorite features, or get input from the community.