CVE-2024-28119: Grav vulnerable to Server Side Template Injection (SSTI) via Twig escape handler

Published Mar 21, 2024
·
Updated

Summary Due to the unrestricted access to twig extension class from grav context, an attacker can redefine the escape function and execute arbitrary commands.

Details https://github.com/twigphp/Twig/blob/3.x/src/Extension/EscaperExtension.php#L99 php / Defines a new escaper to be used via the escape filter. @param string $strategy The strategy name that should be used as a strategy in the escape call @param callable $callable A valid PHP callable / public function setEscaper($strategy, callable $callable) { $this->escapers[$strategy] = $callable; } Twig supports the functionality to redefine the escape function through the setEscaper method. However, that method is not originally exposed to the twig environment, but it is accessible through the payload below.

plaintext {{ grav.twig.twig.extensions.core.setEscaper('a','a') }} At this point, it accepts callable type as an argument, but as there is no validation for the $callable variable, attackers can set dangerous functions like system as the escaper function.

PoC {{ vardump(grav.twig.twig.extensions.core.setEscaper('system','twigarrayfilter')) }} {{ vardump(['id'] | escape('system', 'system')) }}

Impact Twig processing of static pages can be enabled in the front matter by any administrative user allowed to create or edit pages. As the Twig processor runs unsandboxed, this behavior can be used to gain arbitrary code execution and elevate privileges on the instance.

Other sources

Grav is an open-source, flat-file content management system. Prior to version 1.7.45, due to the unrestricted access to twig extension class from grav context, an attacker can redefine the escape function and execute arbitrary commands. Twig processing of static pages can be enabled in the front matter by any administrative user allowed to create or edit pages. As the Twig processor runs unsandboxed, this behavior can be used to gain arbitrary code execution and elevate privileges on the instance. Version 1.7.45 contains a patch for this issue.

MITRE

Affected Software

2 affected componentsFixes available
composer/getgrav/grav<1.7.45
1.7.45
getgrav Grav<1.7.45

Event History

Mar 21, 2024
CVE Published
via MITRE·10:02 PM
Data Sourced
via MITRE·10:02 PM
DescriptionSeverityWeakness
Data Sourced
via NVD·10:15 PM
DescriptionSeverityWeakness
Mar 22, 2024
Advisory Published
via GitHub·04:56 PM

Frequently Asked Questions

1

What is the severity of CVE-2024-28119?

The severity of CVE-2024-28119 is considered high due to the potential for arbitrary command execution.

2

How do I fix CVE-2024-28119?

To fix CVE-2024-28119, upgrade to version 1.7.45 or later of the Getgrav Grav package.

3

What causes CVE-2024-28119?

CVE-2024-28119 is caused by unrestricted access to the Twig extension class from the Grav context.

4

Which versions of Getgrav Grav are affected by CVE-2024-28119?

CVE-2024-28119 affects all versions of Getgrav Grav prior to 1.7.45.

5

What type of vulnerability is CVE-2024-28119?

CVE-2024-28119 is a code execution vulnerability that allows attackers to redefine the escape function.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203