You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The .NET System.IO.Path.GetFileName will take a path, relative or otherwise, and return only the filename part. I am using this to sanitize the input to a Download action that serves files from a hardcoded folder. The initial code looked like this, which is in fact vulnerable:
This still detects "Uncontrolled data used in path expression (cs/path-injection)" for filePath even though it has been tested to no longer serve files outside of filesDir when passing in parameters such as "../../../FileThatShouldntBeServed.txt".
The text was updated successfully, but these errors were encountered:
The .NET
System.IO.Path.GetFileName
will take a path, relative or otherwise, and return only the filename part. I am using this to sanitize the input to a Download action that serves files from a hardcoded folder. The initial code looked like this, which is in fact vulnerable:Corrective action was taken so that only a file name with no additional path will be used to look for the file:
This still detects "Uncontrolled data used in path expression (cs/path-injection)" for
filePath
even though it has been tested to no longer serve files outside offilesDir
when passing in parameters such as "../../../FileThatShouldntBeServed.txt".The text was updated successfully, but these errors were encountered: