CVE-2024-28119
highpriority · track · 36EPSS 0.016 · 75 %ileEUUSEPSS · scored 2026-10-24
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.
cvss
Technical severity, 0–10. One row per scoring source.
base score 0–10 · higher = more severe · hover a vector to decode
ssvc
A stakeholder decision — act, attend, or track — from exploitation and impact.
weaknesses
The CWE weakness classes this flaw belongs to.
affected products (4)
Products and version ranges known to be affected.
advisories (1)
Vendor and ecosystem advisories describing this.
- GHSA-2m7x-c7px-hp58Server Side Template Injection (SSTI) via Twig escape handler2024-03-22ghsa · osvUS
### 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.
also known as (3)
Other names and identifiers for this entity.
sources
Which sources assert this record, and when.
references (10)
External citations — patches, advisories, analysis.
- https://cxsecurity.com/cveshow/CVE-2024-28119/cnnvd
- https://github.com/getgrav/grav/commit/de1ccfa12dbcbf526104d68c1a6bc202a98698fecnnvd
- https://github.com/getgrav/grav/security/advisories/GHSA-2m7x-c7px-hp58cnnvd
- https://github.com/twigphp/Twig/blob/3.x/src/Extension/EscaperExtension.php#L99cnnvd
- https://github.com/getgrav/grav/commit/de1ccfa12dbcbf526104d68c1a6bc202a98698feenisa_euvd
- https://github.com/getgrav/grav/security/advisories/GHSA-2m7x-c7px-hp58enisa_euvd
- https://github.com/twigphp/Twig/blob/3.x/src/Extension/EscaperExtension.php#L99enisa_euvd
- https://github.com/getgrav/grav/commit/de1ccfa12dbcbf526104d68c1a6bc202a98698fePatchnvd
Attackers weaponise vulnerabilities like this against internet-exposed services. See what is exposed on your perimeter with a free passive scan.
Free scan