Skip to content

Commit

Permalink
Updated extraction to extract with key of original file path, extract…
Browse files Browse the repository at this point in the history
…ing to a safe location (#1557)
  • Loading branch information
ebkr authored Nov 16, 2024
1 parent 5e73a77 commit 8563fea
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/providers/generic/zip/AdmZipProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ export default class AdmZipProvider extends ZipProvider {

async extractEntryTo(zip: string | Buffer, target: string, outputPath: string): Promise<void> {
const adm = new AdmZip(zip);
target = target.replace(/\\/g, '/');
const safeTarget = target.replace(/\\/g, '/');
outputPath = outputPath.replace(/\\/g, '/');
var fullPath = path.join(outputPath, target).replace(/\\/g, '/');
var fullPath = path.join(outputPath, safeTarget).replace(/\\/g, '/');
if(!path.posix.normalize(fullPath).startsWith(outputPath))
{
throw Error("Entry " + target + " would extract outside of expected folder");
Expand Down

0 comments on commit 8563fea

Please sign in to comment.