Skip to content

Commit 71bbed1

Browse files
committed
more SSTI fixes in Utils::isDangerousFunction()
1 parent 8c2c1cb commit 71bbed1

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

Diff for: CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
* 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.
66
1. [](#improved)
77
* More robust SSTI handling in `|filter` and `|map`
8+
* Various SSTI improvements `Utils::isDangerousFunction()`
89
1. [](#bugfix)
910
* Fixed Twig `|map()` allowing code execution
1011

Diff for: system/src/Grav/Common/Utils.php

+17-1
Original file line numberDiff line numberDiff line change
@@ -1950,7 +1950,7 @@ public static function getSupportPageTypes(array $defaults = null)
19501950
}
19511951

19521952
/**
1953-
* @param string|array $name
1953+
* @param string|array|Closure $name
19541954
* @return bool
19551955
*/
19561956
public static function isDangerousFunction($name): bool
@@ -2048,8 +2048,24 @@ public static function isDangerousFunction($name): bool
20482048
'posix_setpgid',
20492049
'posix_setsid',
20502050
'posix_setuid',
2051+
'unserialize',
2052+
'ini_alter',
2053+
'simplexml_load_file',
2054+
'simplexml_load_string',
2055+
'forward_static_call',
2056+
'forward_static_call_array',
20512057
];
20522058

2059+
$name = strtolower($name);
2060+
2061+
if ($name instanceof \Closure) {
2062+
return false;
2063+
}
2064+
2065+
if (strpos($name, "\\") !== false) {
2066+
return false;
2067+
}
2068+
20532069
if (is_array($name) || strpos($name, ":") !== false) {
20542070
return false;
20552071
}

0 commit comments

Comments
 (0)