null byte injection check

main
Robert 2 years ago
parent 3772e4d386
commit adbc870914
  1. 9
      src/bootstrap/requires.php
  2. 2
      src/classes/database/paginate.php

@ -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://

@ -41,7 +41,7 @@ class paginate {
return ($limit > $this->max_limit) ? $this->max_limit : $limit;
}
public function mongo_get_data(int $limit = 10, int $page = 1, array $options) {
public function mongo_get_data(int $limit = 10, int $page = 1, array $options = []) {
$this->_limit = $this->set_limit($limit); // Number of items per page
$this->_page = $page; // The current page number

Loading…
Cancel
Save