|
|
|
|
@ -20,10 +20,15 @@ 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 |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|