VYPR
High severityNVD Advisory· Published Jul 18, 2023· Updated Oct 18, 2024

Server-side Template Injection (SSTI) in grav

CVE-2023-37897

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.

PackageAffected versionsPatched versions
getgrav/gravPackagist
< 1.7.42.21.7.42.2

Affected products

1

Patches

2
b4c62101a430

SSTI attack mitigation - GHSA-9436-3gmp-4f53

https://github.com/getgrav/gravAndy MillerJul 18, 2023via ghsa
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)) {
    
71bbed12f950

more SSTI fixes in Utils::isDangerousFunction()

https://github.com/getgrav/gravAndy MillerJun 13, 2023via ghsa
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

News mentions

0

No linked articles in our index yet.