Hoch

grav Server-side Template Injection (SSTI) mitigation bypass

  • Veröffentlicht: 19.07.2023
  • Aktualisiert: 11.10.2026 10:22

Summary

The fix for SSTI 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 (\\)

Details

The isDangerousFunction() check in version 1.7.42 and onwards retuns false value instead of true when the \ symbol is found in the $name.

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

        if (in_array($name, $commandExecutionFunctions)) {
            return true;
        }
...

Based on the code where the function is used, it is expected that any dangerous condition would return true

php
    /**
     * @param Environment $env
     * @param array $array
     * @param callable|string $arrow
     * @return array|CallbackFilterIterator
     * @throws RuntimeError
     */
    function mapFunc(Environment $env, $array, $arrow)
    {
        if (!$arrow instanceof \Closure && !is_string($arrow) || Utils::isDangerousFunction($arrow)) {
            throw new RuntimeError('Twig |map("' . $arrow . '") is not allowed.');
	}

when |map('\system') is used in the malicious payload, the single backslash is dropped prior to reaching strpos($name, '\\') check, thus $name variable already has no backslash, and the command is blacklisted because it reaches the if (in_array($name, $commandExecutionFunctions)) { validation step.

However if |map('\\system') is used (i.e. double backslash), then the strpos($name, "\\") !== false takes effect, and isDangerousFunction() returns false , in which case the RuntimeError is not generated, and blacklist is bypassed leading to code execution.

Exploit Conditions

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

Steps to reproduce

  1. Log in to Grav Admin using an administrator account.
  2. Navigate to Accounts > Add, and ensure that the following permissions are assigned when creating a new low-privileged user:
    • Login to Admin - Allowed
    • Page Update - Allowed
  3. Log out of Grav Admin
  4. Login using the account created in step 2.
  5. Choose Pages -> Home
  6. Click the Advanced tab and select the checkbox beside Twig to ensure that Twig processing is enabled for the modified webpage.
  7. Under the Content tab, insert the following payload within the editor: {{ ['id'] | map('\\system') | join() }}
  8. Click the Preview button. Observe that the output of the id shell command is returned in the preview.

Mitigation

diff
diff --git a/system/src/Grav/Common/Utils.php b/system/src/Grav/Common/Utils.php
index 2f121bbe3..7b267cd0f 100644
--- a/system/src/Grav/Common/Utils.php
+++ b/system/src/Grav/Common/Utils.php
@@ -2069,7 +2069,7 @@ abstract class Utils
         }
 
         if (strpos($name, "\\") !== false) {
-            return false;
+            return true;
         }
 
         if (in_array($name, $commandExecutionFunctions)) {

Betroffene Software

Klicken Sie auf eine Technologie, um alle zugehörigen Schwachstellen anzuzeigen.

PlattformPaketAnfällige VersionenBehoben in
Composer-Paket getgrav/grav < 1.7.42.2 1.7.42.2

Verweise

CVSS-Wert 7.2/10
CVSS-Vektor
CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:U/C:H/I:H/A:H
Schwäche (CWE)
CWE-393, CWE-74
Plattform
Composer
Paket
getgrav/grav
Veröffentlicht
19.07.2023
Aktualisiert
11.10.2026 10:22

Quellen und Lizenzen

OSV / GitHub Advisory Database - GHSA-9436-3gmp-4f53 - CC BY 4.0

Schwachstellenhistorie: getgrav/grav

Alle veröffentlichten Schwachstellen dieses Pakets (Composer-Paket), neueste zuerst. Zeigt, ob es ein einmaliger Ausrutscher ist oder ein Paket, das man im Auge behalten muss.

Alle (99) im Archiv
Einträge insgesamt
99
Erste → letzte
11.2019 09.2026
Ohne Fix
6
In Angriffen ausgenutzt
0

Verteilung nach Schweregrad

  • Kritisch 7
  • Hoch 47
  • Mittel 41
  • Niedrig 4

Veröffentlichungen pro Jahr

  1. 2019: 1
  2. 2020: 1
  3. 2021: 4
  4. 2022: 10
  5. 2023: 5
  6. 2024: 8
  7. 2025: 23
  8. 2026: 47
Schweregrad:
  1. Hoch · 8.8 CVE-2026-72819 < 2.0.13 2.0.13
  2. Hoch CVE-2026-53653 >= 2.0.0-beta.1, < 2.0.0-rc.8, < 1.7.53 2.0.0-rc.8, 1.7.53
  3. Hoch · 8.9 CVE-2026-42611 < 2.0.0-beta.2 2.0.0-beta.2
  4. Hoch · 8.5 CVE-2026-42612 < 2.0.0-beta.2 2.0.0-beta.2
  5. Kritisch · 9.4 CVE-2026-42613 < 2.0.0-beta.2 2.0.0-beta.2
  6. Kritisch · 9.1 CVE-2025-66844 <= 1.7.49.5 keine Korrektur
  7. Hoch CVE-2025-66298 < 1.8.0-beta.27 1.8.0-beta.27
  8. Hoch CVE-2025-66294 < 1.8.0-beta.27 1.8.0-beta.27
  9. Hoch · 8.5 CVE-2025-66300 < 1.8.0-beta.27 1.8.0-beta.27
  10. Hoch · 8.8 CVE-2025-66299 < 1.8.0-beta.27 1.8.0-beta.27
  11. Hoch · 8.5 CVE-2024-34082 < 1.7.46 1.7.46
  12. Hoch · 8.8 CVE-2024-28119 < 1.7.45 1.7.45
  13. Hoch · 8.8 CVE-2024-28118 < 1.7.45 1.7.45
  14. Hoch · 8.8 CVE-2024-28117 < 1.7.45 1.7.45
  15. Hoch · 8.8 CVE-2024-27921 < 1.7.45 1.7.45
  16. Hoch · 8.8 CVE-2024-27923 < 1.7.43 1.7.43
  17. grav Server-side Template Injection (SSTI) mitigation bypass dieser Eintrag
    Hoch · 7.2 CVE-2023-37897 < 1.7.42.2 1.7.42.2
  18. Hoch · 7.2 CVE-2023-34448 < 1.7.42 1.7.42
  19. Hoch · 7.2 CVE-2023-34252 < 1.7.42 1.7.42
  20. Kritisch · 9.1 CVE-2023-34251 < 1.7.42 1.7.42
  21. Hoch · 7.2 CVE-2022-2073 < 1.7.34 1.7.34
  22. Hoch · 8.1 CVE-2020-29555 >= 1.7.0-beta.1, <= 1.7.0-rc.17, < 1.6.30 1.6.30
  23. Hoch · 8.8 CVE-2020-29553 >= 1.7.0-beta.1, <= 1.7.0-rc.17, < 1.6.30 1.6.30
  24. Hoch · 7.1 CVE-2022-0970 < 1.7.31 1.7.31
  25. Hoch · 8.8 CVE-2021-3924 <= 1.7.24 keine Korrektur
  26. Hoch · 8.4 CVE-2021-29440 < 1.7.11 1.7.11

Erkennen Sie Schwachstellen in Ihrer Anwendung

Mit der DockRay-Integration und aktivierter Softwareinventarisierung prüft DockRay gemeldete Komponentenversionen auf bekannte Schwachstellen und benachrichtigt Sie über bestätigte Treffer. Die Abdeckung hängt von der unterstützten Technologie und den verfügbaren Meldungen ab.

Anwendung verbinden
DockRay Newsletter

Anwendungssicherheit in Ihrem Postfach

Wichtige Schwachstellen, konkrete Empfehlungen und praktische Tipps für Ihre Anwendungen. Wählen Sie Ihre Technologien und verfolgen Sie, was für Ihr Projekt relevant ist.

  • Eine tägliche Zusammenfassung neuer Schwachstellen, auch kritischer.
  • Benachrichtigungen über wichtige Updates.
  • Praktische Tipps zur Sicherheit und Überwachung von Anwendungen.

Leer lassen, um Meldungen zu allen Technologien zu erhalten.

Kostenlos anmelden. In jeder E-Mail mit einem Klick abmelden.