|
|
|
|
@ -20,13 +20,18 @@ final class requires { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static function is_dangerous(string $file): bool { |
|
|
|
|
// Make sure the file does not contain null bytes to avoid PHAR file attacks |
|
|
|
|
if (strpos($file, "\x00") !== false) { |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Remove non-visible characters |
|
|
|
|
$file = preg_replace('/[\x00-\x1F\x7F]/u', '', $file); |
|
|
|
|
|
|
|
|
|
if (strpos($file, "..") !== false) { |
|
|
|
|
if (strpos($file, "..") !== false || strpos($file, "./") !== false) { |
|
|
|
|
return true; // .. Too dangerious, up path attack |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* |
|
|
|
|
* :// Too dangerious, PHAR file execution of serialized code injection, etc... |
|
|
|
|
* Also, prevent remote code execution from http://, ftp:// |
|
|
|
|
|