SP233270 (Community Member) asked a question.

Directory Traversal CWE -73 Issue with File file = new FilenameUtils.normalize(../../etc/passwd) ; Flaw detected

 

Project uses normalize() to generated file path based on windows\linux but in VeraCode Static scan report this method used line detected as Directory Traversal(CWE-73) issue as medium flaws.

Common.io 2.6 API Unexpected behavior with normalize(String s) method is not performing validations on path input. "../ " is allowing but somehow return as Null. If the input type is some thing like "../../". with the below lines of code checks can it be remove path DT vulnerabilities issue ? or Regex validation required to fix flaws.

Could somebody please give correct solution.

 

fileName = "../../etc/passwd";

fileName = FilenameUtils.normalize(fileName); // still holds the same value ("//../foo") 

if (fileName != null) {

// file creation path eg: drivec\root\06-03-2020\folder\test 

else {

throw new CustomerException("Invalid path creation found");

}

 

 


Topics (3)

No articles found
Loading

Ask the Community

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