Veracode directory traversal Issue c#

寵の児 提交于 2019-12-05 18:45:31

According to the code you've posted here, that looks like a false positive.

Veracode is apparently tracking the inputFileName variable (which I assume contains unvalidated user input), and notes that it influences the extension variable. Since you later embed extension directly into the filename, and read the file that points at, Veracode sees that it is possible that a malicious user would embed a partial path in inputFileName which would then change the directory of the target file...

In this case, Veracode is missing the fact that you already performed input validation (the extension == ".csv" check), and absolutely constrained the relevant part of the input to a tight whitelist.

Assuming there is no other relevant bits of code missing from your question, this is safe to mark as false positive.

There's no real way for static analyzers to reliably verify that you are in fact not using user input. They tend to err on the side of being overly cautious, thereby producing false-positive warnings.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!