llamaCVEVulnerability Intelligence
/
Advisory · GitHub · Packagist · getgrav/grav

GHSA-XX48-97M4-H7QM

Remote code execution via Twig Server-side template injection in Grav CMS 2.0.11

Texto original en inglés · Ver en español

Parche disponible
Descargar PNG JSON
CVSS
—
high
Fuente: —
ExplotaciónSin evidenciaNo figura en CISA KEV
Exploits públicos0Ninguno conocido
Parche1 versión2.0.13
Exposición118 dDesde la divulgación, 26 jul 2026, 7:56 a. m.
Detección115 dDesde la divulgación hasta su ingreso al índice
Decisión estimadaSeguir
Remediar en la ventana regular de mantenimiento
Estimación de Llama con el árbol SSVC de CISA a partir de la severidad declarada por GHSA (alta) y la evidencia de explotación (sin evaluación oficial): sin explotación conocida, no automatizable e impacto técnico parcial. Hay versiones corregidas disponibles.
Revisa si tu versión cae en el rango. Te espero.No corre prisa, pero no la pierdas de vista.
Timeline

Ciclo de vida de la vulnerabilidad

Hoy
Divulgación
Publicada
Explotación
Remediación
Monitoreo
Detectada +1
26 jul 26
18 nov 26
21 nov 26
26 jul 26
25 ago 26
23 sept 26
23 oct 26
21 nov 26
FechaFaseEventoDetalle
Divulgación Publicada GHSA-XX48-97M4-H7QM divulgada
Monitoreo Detectada Ingresó al índice
Monitoreo Verificada Última verificación contra las fuentes
Resumen
Descripción del advisory
Texto original · GitHub · en inglés
Summary

A low-privileged page editor (any account that can create or edit a page) can execute arbitrary operating-system commands on the server. Grav sandboxes Twig in normal editor content, but a form's email-action parameters (subject, body, to, from) are rendered as Twig with the sandbox turned off. An editor puts a Twig payload in the email subject; the command runs whenever the form is submitted (by anyone, including an anonymous visitor), and even when no working mail server is configured, because it fires while the message is being built. This is full server takeover from a restricted role.

Details

Grav intentionally stops non-super editors from running arbitrary Twig. Two mechanisms normally enforce that:

  • The Twig sandbox is enabled only for editor-controlled sources. The source policy in `system/src/Grav/Common/Twig/Sandbox/GravSourcePolicy.php` turns the sandbox on only for template names starting with `@Page:` or `@Var:`:

```php
return str_starts_with($name, '@Page:') || str_starts_with($name, '@Var:');
```

  • Grav also replaces the `filter`, `map` and `reduce` Twig filters with hardened versions that reject dangerous callables regardless of the sandbox. See `system/src/Grav/Common/Twig/Extension/GravExtension.php` (registrations around lines 182-184, guard `Utils::isDangerousFunction($arrow)`), e.g.:

```php
if (!$arrow instanceof \Closure && !is_string($arrow) || Utils::isDangerousFunction($arrow)) {
throw new RuntimeError('Twig |map("' . $arrow . '") is not allowed.');
}
```

Two gaps combine into RCE:

  1. Email-action parameters are rendered as UNSANDBOXED Twig. The Email plugin renders each param through `processTwigString()` in `user/plugins/email/classes/Email.php` (around line 416), which registers the string under a template name prefixed `@EmailVar:`:

```php
$name = '@EmailVar:' . md5($string);
...
return $twig->twig->render($name, $vars);
```

Because `@EmailVar:` is neither `@Page:` nor `@Var:`, the source policy above does NOT enable the sandbox for it. So these strings run with the full Twig surface. This path is reached from `buildMessage()` -> `processParams()` (around line 204/389) while the message is assembled, before any send.

  1. The `find` filter is not one of the filters Grav hardens. `filter`, `map` and `reduce` are overridden and always reject dangerous functions, but `find` falls through to Twig core's `find`, which only blocks callables when the sandbox is active. In the unsandboxed `@EmailVar:` render the sandbox is off, so `find` happily calls a string function such as `system`.

Exploit primitive:

{{ ['id > /tmp/pwned 2>&1']|find('system') }}

`find` calls `system('id > /tmp/pwned 2>&1')` as its test callback, running the command. It must be `find` (not `map`/`filter`, which Grav blocks). The Email plugin is active in a default install (its engine defaults to sendmail), and the command runs during message build, so no reachable mail server is required.

PoC
  1. Log in to the admin panel (you can use the admin account, or any account that can edit pages).
  1. Create a new page using the Form page template. Edit the created page in expert mode and put the following payload into the Frontmatter field:

```yaml
title: Contact
form:
name: rceform
fields:
- name: email
type: text
process:
- email:
from: x@x.com
to: x@x.com
subject: "{{ ['id > /tmp/pwned 2>&1']|find('system') }}"
body: hi
- message: Thanks
```

  1. Save the page. Note its address, for example http://localhost:8000/contact.
  1. Open that page in a browser. You will see a small form with one field.
  1. Fill in anything and press Enter.
  1. The command has now run on the server. In this example, `/tmp/pwned` now contains the output of the `id` command.
Impact

Unsandboxed-Twig / template-injection leading to remote code execution.

  • Who can exploit it: any account with page-edit rights — the exact restricted "editor" role Grav's Twig sandbox is meant to contain. It escalates that role into arbitrary command execution and full server compromise.
  • Who is affected: the server and everything on it. The command runs with the web server's privileges. Triggering only needs someone to submit the form, which can be the attacker themselves or any anonymous visitor.

Suggested fix: render email-action parameters through the same sandboxed Twig path used for other editor content (so `@EmailVar:` is sandboxed), and/or harden the `find` filter the same way `map`/`filter`/`reduce` are hardened so it cannot invoke dangerous functions.

Incluye detalles técnicos publicados por el investigador. Úselos solo para validar y corregir sus propios sistemas.

Versiones

Rangos afectados

Afectada Corregida
getgrav/grav≥ 2.0.0 < 2.0.13
2.0.0
2.0.13
Remediación

Estado del parche por paquete

Paquete / productoEstadoCorregida enDesde divulgaciónÚltima versión
Packagistgetgrav/grav
Corregida 2.0.13 — —
Versiones corregidas2.0.13
Explotación

Arsenal público

Sin exploits, módulos ni PoC públicos conocidos a la fecha de verificación.

Referencias
Advisoryhttps://github.com/getgrav/grav/security/advisories/GHSA-xx48-97m4-h7qm

Las referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.