Skip to content

Commit

Permalink
more SSTI fixes in Utils::isDangerousFunction()
Browse files Browse the repository at this point in the history
  • Loading branch information
rhukster committed Jun 13, 2023
1 parent 8c2c1cb commit 71bbed1
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* Added a new `system.languages.debug` option that adds a `<span class="translate-debug"></span>` around strings translated with `|t`. This can be styled by the theme as needed.
1. [](#improved)
* More robust SSTI handling in `|filter` and `|map`
* Various SSTI improvements `Utils::isDangerousFunction()`
1. [](#bugfix)
* Fixed Twig `|map()` allowing code execution

Expand Down
18 changes: 17 additions & 1 deletion system/src/Grav/Common/Utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -1950,7 +1950,7 @@ public static function getSupportPageTypes(array $defaults = null)
}

/**
* @param string|array $name
* @param string|array|Closure $name
* @return bool
*/
public static function isDangerousFunction($name): bool
Expand Down Expand Up @@ -2048,8 +2048,24 @@ public static function isDangerousFunction($name): bool
'posix_setpgid',
'posix_setsid',
'posix_setuid',
'unserialize',
'ini_alter',
'simplexml_load_file',
'simplexml_load_string',
'forward_static_call',
'forward_static_call_array',
];

$name = strtolower($name);

if ($name instanceof \Closure) {
return false;
}

if (strpos($name, "\\") !== false) {
return false;
}

if (is_array($name) || strpos($name, ":") !== false) {
return false;
}
Expand Down

0 comments on commit 71bbed1

Please sign in to comment.