GHSA-V6JH-QC33-H6GF
Publishers can run server code through a Host header that turns the pages folder into the configuration environment
Texto original en inglés · Ver en español
Ciclo de vida de la vulnerabilidad
| Fecha | Fase | Evento | Detalle |
|---|---|---|---|
| Divulgación | Publicada | GHSA-V6JH-QC33-H6GF divulgada | |
| Monitoreo | Detectada | Ingresó al índice | |
| Monitoreo | Verificada | Última verificación contra las fuentes |
Summary
A Grav account that can only edit pages and page media (for example the stock `editor` role using the REST API) can run arbitrary shell commands as the web server user by sending API requests with the header `Host: pages`. This escapes the Twig content sandbox. It works on the shipped layout, where `user/env/` does not exist, whenever the web server hands an unrecognized Host to Grav, as a default or catch-all virtual host does. That is the common layout of single-site servers.
Affected versions
Grav 2.x from 2.0.0 up to and including 2.2.17. The Host-derived environment folder is old (first released in 0.9.6), and it became a sandbox escape when the Twig content sandbox arrived in 2.0.0-beta.2. Grav 1.7 has the same fallback but no sandbox to escape, and exploiting it there needs a publisher account, so it is not part of this advisory's patched releases.
Details
When `user/env/` is missing, `Setup` joins the request's Host to `user://` and accepts the result as the environment folder if it is any existing directory. `Host: pages` therefore turns `user/pages`, the tree that publishers write, into the environment, and every `user/pages/config/**/*.yaml` is merged over the site configuration. A publisher builds that YAML from pieces they control: nested page folders named after a configuration key path, and a media `.meta.yaml` sidecar written by setting a file's metadata. Together these add a `themes.<theme>.streams.schemes.theme.prefixes` entry, which becomes a Twig namespace over one of the publisher's own page folders. Templates loaded from a namespace are not sandboxed, so a page that includes an uploaded `.txt` file from it runs that file as unsandboxed Twig.
The reproducer does everything as `editor` through `/api/v1`. It returns the SHA-256 of a nonce piped through `sha256sum` when the request carries `Host: pages`, while the same page rendered with the site's own host only shows sandboxed output. The same overlay can switch on the DebugBar for anonymous `Host: pages` requests and show the full plugin configuration, including mail credentials. With `Host: media`, the API plugin's media rename of a `*.meta.yaml` sidecar can widen the `read_file` allowlists.
Impact
A publisher gets code execution as the web server user, which means every secret on the server and a forged super-admin token. The attacker needs a page and media editing account and a site that answers unknown Host values, so the rating is High.
Patches
Fixed in Grav 2.2.18. A folder that another `user://` stream already serves (such as pages, data or accounts), or that lies inside one, is no longer accepted as the Host-derived environment folder, and a Host value that is not a single folder name (it contains `/` or `\`, or starts with a dot) gets no environment folder at all. As hardening, update the API plugin to 1.1.6 as well: it refuses a media rename that has a `*.meta.yaml` or `media_order.yaml` file as its source or target.
Workarounds
Make the web server answer only for the site's own names (a `ServerName` plus a catch-all virtual host that returns an error), so a forged Host never reaches Grav.
Credits
Discovered by Anthropic's OSS Scanner (ANT-2026-H452L6V9).
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.2.18 | — | — |
2.2.18Arsenal 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-v6jh-qc33-h6gfLas referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.
