dotnet / dotnet/dotnet-api-docs
How to safely handle file paths and check for valid paths
- Dominant language
- C#
- Stars
- 949
- Forks
- 1.7k
- Avg merge
- 3d 27m
- Merged PRs (30d)
- 49
Description
## How to safely handle file paths and check for valid paths
From dotnet/dotnet-api-docs#877 (https://github.com/dotnet/dotnet-api-docs/issues/877)
We should extend this to document how to safely check for path containment (as we've done for the example for [ExtractToFile](https://docs.microsoft.com/en-us/dotnet/api/system.io.compression.zipfileextensions.extracttofile?view=netcore-2.1#System_IO_Compression_ZipFileExtensions_ExtractToFile_System_IO_Compression_ZipArchiveEntry_System_String_System_Boolean_), etc.)
Maybe a linked article from Path.Join/Combine/GetFullPath on how to safely handle paths? Basically something discussing directory traversal attacks and how to check for one path being contained within another...
The most salient point would be that you should always fully normalize user input paths (untrusted input) and be aware of combination gotchas.
See dotnet/dotnet-api-docs#877
//cc @JeremyKuhne
Contributor guide
Assessment
This issue has not been assessed yet.