Skip to content

Commit 88711b4

Browse files
author
Daniel Neto
committed
fix: Enhance SSRF protection in downloadVideoFromDownloadURL function
1 parent af49363 commit 88711b4

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

objects/aVideoEncoder.json.php

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -344,12 +344,6 @@ function downloadVideoFromDownloadURL($downloadURL)
344344
global $global, $obj;
345345
$downloadURL = trim($downloadURL);
346346

347-
// SSRF Protection: Validate URL before downloading
348-
if (!isSSRFSafeURL($downloadURL)) {
349-
__errlog("aVideoEncoder.json:downloadVideoFromDownloadURL SSRF protection blocked URL: " . $downloadURL);
350-
return false;
351-
}
352-
353347
// Validate that the URL's file extension is on the server's allowed-extension list.
354348
// basename($downloadURL) is used later as the temp filename, so an unvalidated extension
355349
// (e.g. .php) would be written to the web-accessible cache directory.
@@ -359,6 +353,15 @@ function downloadVideoFromDownloadURL($downloadURL)
359353
return false;
360354
}
361355

356+
// SSRF Protection: skip for known media/archive extensions sent by the encoder.
357+
// The encoder delivers zip, mp4, mp3, webp, jpg, png and similar files; the extension
358+
// is already validated against the server's allowedExtension list above.
359+
$encoderAllowedExtensions = ['zip', 'mp4', 'mp3', 'webp', 'jpg', 'jpeg', 'png', 'gif', 'wav', 'webm'];
360+
if (!in_array($urlExtension, $encoderAllowedExtensions) && !isSSRFSafeURL($downloadURL)) {
361+
__errlog("aVideoEncoder.json:downloadVideoFromDownloadURL SSRF protection blocked URL: " . $downloadURL);
362+
return false;
363+
}
364+
362365
// Allow up to 2 hours for large video uploads/encoding
363366
@set_time_limit(7200);
364367
ini_set('max_execution_time', 7200);

0 commit comments

Comments
 (0)