GHSA-RFR9-7H4P-GX2X
Twig content sandbox leaks the full configuration through print_r
Texto original en inglés · Ver en español
Ciclo de vida de la vulnerabilidad
| Fecha | Fase | Evento | Detalle |
|---|---|---|---|
| Divulgación | Publicada | GHSA-RFR9-7H4P-GX2X divulgada | |
| Monitoreo | Detectada | Ingresó al índice | |
| Monitoreo | Verificada | Última verificación contra las fuentes |
Summary
A user with page-edit rights can read Grav's entire merged configuration — including plugin secrets and other values the content sandbox is specifically built to hide — by rendering `{{ config|print_r }}` in page content.
This is an incomplete fix for GHSA-mc5q-6hpj-rp7j. That advisory added a guard to the dump and serialize filters (`print_r`, `vardump`, `json_encode`, `yaml_encode`, `string`) so they would refuse objects inside sandboxed content. The guard has never run.
Affected versions
Grav 2.0.0-rc.1 through 2.0.21. Fixed in 2.0.22.
Grav 1.7 is not affected: it ships no Twig content sandbox, so it has no such guard to fail.
Details
`GravExtension::assertSandboxDumpSafe()` decided whether it was inside a sandboxed render by calling `SandboxExtension::isSandboxed()` with no `Source` argument. That form of the call reports only the *global* sandbox flag.
Grav never turns the sandbox on globally. It registers a `SandboxExtension` carrying a `GravSourcePolicy`, which decides per template: anything loaded as `@Page:` or `@Var:` is sandboxed, a theme file on disk is not. Under that wiring the global flag is false for every render Grav performs, so the guard returned early every time and the dump filters behaved exactly as they had before the fix.
`print_r` reflects private and protected state directly, without passing through the sandbox's member gate. The `config` variable inside a sandboxed render is a `SandboxConfig` facade that redacts denied paths on every read — but it holds the real `Config` object in a private property, and `print_r` walks straight into it.
The mechanism was not caught earlier because the fix shipped without tests, and the nearest existing tests construct their environment as `new SandboxExtension($policy, true)` — sandboxed globally — which is the single condition under which the dead check passes.
Proof of concept
On a stock 2.0.21 install, with `security.twig_sandbox.enabled: true` and `security.twig_content.config_access: false` (both defaults), save a page with Twig processing on and this body:
{{ config|print_r }}Requesting the page returns roughly 1.1 MB of HTML containing the full configuration tree — around 12,000 keys, including `plugins.*` and every other path the facade is configured to deny. A marker value placed in `user/config/system.yaml` appears in the response, confirming this is the site's real merged configuration and not blueprint defaults.
Impact
Any account with page-edit rights — the lowest content role Grav grants — can read configuration it was never granted, including SMTP credentials, API tokens, webhook secrets and cache backend passwords held in plugin configuration. This is an escape from the publisher trust scope, not a capability that scope includes.
Patches
Upgrade to Grav 2.0.22.
The guarded dump and serialize filters are now registered with Twig's `needs_is_sandboxed` flag, so they receive the resolved sandbox state of the calling template rather than asking for a global flag Grav never sets — the same mechanism the `|find` and `|sort` filters already used. Regression tests now exercise these filters through `GravSourcePolicy` rather than a globally sandboxed environment.
Credits
Reported by @Vectrain51.
The original report described the leak as reachable by an unauthenticated visitor through a public form field. We were not able to reproduce that path: every `Twig::processString()` call site in core and in the Form and Email plugins renders an operator-authored string, and submitted form values are interpolated as variables rather than parsed as template source. The underlying leak is real and is reproduced above through page content; the affected trust boundary is publisher-to-operator rather than anonymous-to-operator, and the advisory is rated accordingly.
Incluye detalles técnicos publicados por el investigador. Úselos solo para validar y corregir sus propios sistemas.
Rangos afectados
Estado del parche por paquete
| Paquete / producto | Estado | Corregida en | Desde divulgación | Última versión |
|---|---|---|---|---|
Packagistgetgrav/grav |
Corregida | 2.0.22 | — | — |
2.0.22Arsenal público
Sin exploits, módulos ni PoC públicos conocidos a la fecha de verificación.
https://github.com/getgrav/grav/security/advisories/GHSA-rfr9-7h4p-gx2xLas referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.
