Server-side Template Injection (SSTI) in grav
Description
Grav is a file-based Web-platform built in PHP. Grav is subject to a server side template injection (SSTI) vulnerability. The fix for another SSTI vulnerability using |map, |filter and |reduce twigs implemented in the commit 71bbed1 introduces bypass of the denylist due to incorrect return value from isDangerousFunction(), which allows to execute the payload prepending double backslash (\\). The isDangerousFunction() check in version 1.7.42 and onwards retuns false value instead of true when the \ symbol is found in the $name. This vulnerability can be exploited if the attacker has access to: 1. an Administrator account, or 2. a non-administrator, user account that has Admin panel access and Create/Update page permissions. A fix for this vulnerability has been introduced in commit b4c6210 and is included in release version 1.7.42.2. Users are advised to upgrade. There are no known workarounds for this vulnerability.
Affected packages
Versions sourced from the GitHub Security Advisory.
| Package | Affected versions | Patched versions |
|---|---|---|
getgrav/gravPackagist | < 1.7.42.2 | 1.7.42.2 |
Affected products
1Patches
2b4c62101a430SSTI attack mitigation - GHSA-9436-3gmp-4f53
3 files changed · +12 −1
CHANGELOG.md+7 −0 modified@@ -1,3 +1,10 @@ +# v1.7.42.2 +## mm/dd/2023 + +2. [](#improved) + * In `Utils::isDangerousFunction`, handle double `\\` in `|map` twig filter to mitigate SSTI attack + * Better handle empty email in `Validatoin::typeEmail()` + # v1.7.42.1 ## 06/15/2023
system/src/Grav/Common/Data/Validation.php+4 −0 modified@@ -631,6 +631,10 @@ public static function typeColor($value, array $params, array $field) */ public static function typeEmail($value, array $params, array $field) { + if (empty($value)) { + return false; + } + if (!isset($params['max'])) { $params['max'] = 320; }
system/src/Grav/Common/Utils.php+1 −1 modified@@ -2069,7 +2069,7 @@ public static function isDangerousFunction($name): bool } if (strpos($name, "\\") !== false) { - return false; + return true; } if (in_array($name, $commandExecutionFunctions)) {
71bbed12f950more SSTI fixes in Utils::isDangerousFunction()
2 files changed · +18 −1
CHANGELOG.md+1 −0 modified@@ -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
system/src/Grav/Common/Utils.php+17 −1 modified@@ -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 @@ -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; }
Vulnerability mechanics
Generated by null/stub on May 9, 2026. Inputs: CWE entries + fix-commit diffs from this CVE's patches. Citations validated against bundle.
References
5- github.com/advisories/GHSA-9436-3gmp-4f53ghsaADVISORY
- nvd.nist.gov/vuln/detail/CVE-2023-37897ghsaADVISORY
- github.com/getgrav/grav/commit/71bbed12f950de8335006d7f91112263d8504f1bghsax_refsource_MISCWEB
- github.com/getgrav/grav/commit/b4c62101a43051fc7f5349c7d0a5b6085375c1d7ghsax_refsource_MISCWEB
- github.com/getgrav/grav/security/advisories/GHSA-9436-3gmp-4f53ghsax_refsource_CONFIRMWEB
News mentions
0No linked articles in our index yet.