[Archive extraction] Remove leading slashes to prevent absolute path attack.

This commit is contained in:
2023-10-08 00:23:07 +01:00
parent 34611a90c9
commit 278de1cf26

View File

@@ -258,6 +258,9 @@ sealed class ArchiveExtractCommand : Command
Replace('/', '\\');
}
// Prevent absolute path attack
fileName = fileName.TrimStart('\\').TrimStart('/');
string outputPath = Path.Combine(outputDir, fileName);
string destinationDir = Path.GetDirectoryName(outputPath);
if(destinationDir is not null)