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 recommended way of writing an output file from a zip archive entry is to:
1. Use Path.Combine(destinationDirectory, archiveEntry.FullName) to determine the raw output path.
2. Use Path.GetFullPath(..) on the raw output path to resolve any directory traversal elements.
3. Use Path.GetFullPath(destinationDirectory + Path.DirectorySeparatorChar) to determine the fully resolved path of the destination directory.
4. Validate that the resolved output path StartsWith the resolved destination directory, aborting if this is not true.
The recommendation is to do 1, 2, 3 and 4, not only 1. Path.Combine does not perform any sanitization of the entry full path
Activity
iSazonov commentedon Oct 11, 2018
I don't see a problem - we use recommended
Path.Combine(destination, entry.FullName);xcorail commentedon Oct 11, 2018
Hi Ilya (@iSazonov)
The recommendation is to do 1, 2, 3 and 4, not only 1.
Path.Combinedoes not perform any sanitization of the entry full pathCheers
iSazonov commentedon Oct 11, 2018
Xavier RENE-CORAIL (@xcorail) Thanks for clarify!
Travis Plunk (@TravisEz13) We have already this in CoreFX https://source.dot.net/#System.IO.Compression.ZipFile/System/IO/Compression/ZipFileExtensions.ZipArchiveEntry.Extract.cs,104
TravisEz13 commentedon Nov 14, 2018
Fixed in #8252