GHSA-JC8Q-6VCJ-4X25
Media-only accounts and anonymous uploaders can inject Twig into pages through media metadata and file names
Texto original en inglés · Ver en español
Ciclo de vida de la vulnerabilidad
| Fecha | Fase | Evento | Detalle |
|---|---|---|---|
| Divulgación | Publicada | GHSA-JC8Q-6VCJ-4X25 divulgada | |
| Monitoreo | Detectada | Ingresó al índice | |
| Monitoreo | Verificada | Última verificación contra las fuentes |
Summary
Grav builds an image's markup from its metadata sidecar and its file name. That text is HTML-escaped but is not protected against Twig, so Twig written into a picture's title, alt text, class, id or file name runs as page content Twig on any page that shows the picture. An account limited to media management (for example `api.media.*` with no page rights), or an anonymous visitor who uploads through a public form, can use this to run Twig on pages they cannot edit. Together with the `autoescape` tag it serves script to every visitor, a signed-in super admin included.
Affected versions
Grav 2.x from 2.0.0 up to and including 2.2.17. Page Twig is on by default for every page since Grav 2.0.19. Before that only pages with `process.twig: true` were exposed. Grav 1.7 has the same metadata and file-name flow, and 1.7 content Twig is not sandboxed, so a 1.7 page that enables Twig, accepts public uploads and shows a thumbnail link could give an anonymous uploader full Twig. That has not been reproduced and is being evaluated separately.
Details
`MediaObjectTrait::parsedownElement()` fills title, alt, class and id from the sidecar, and the medium URL puts the raw file name into `src`. Parsedown escapes HTML, but it leaves Twig delimiters (`{{`, `{%`) alone, and `Utils::checkFilename()` refuses `<`, `>` and `"` while accepting `{`, `}`, `%` and `|`. The placeholders that protect the page author's own Twig do not cover text derived from a medium, so that text reaches `Twig::processPage()` and is evaluated.
There are three actors. First, an API account holding only `api.media.*` (a role the API plugin explicitly keeps apart from page rights) patches a picture's title through the metadata endpoint. The reproducer uses a `photodesk` account and shows `<img src=x onerror=alert(document.domain)>` served on `/about`, a page that account cannot read or edit. Second, an anonymous visitor on a default configuration uploads through a public Form `type: file` field stored in the page folder, when the page also shows another medium with `?link`, `?lightbox` or `?display=thumbnail`: a file name such as `terms.pdf.thumb.{...}.png` becomes the thumbnail `src`. Third, anonymous visitors on sites with `auto_metadata_exif` enabled (off by default) can use the IPTC title. Script needs `{% autoescape false %}`. Without it, anonymous Twig still prints protected or unpublished page content, and `{{` in a file name makes the page answer 500.
Impact
An account with media rights only, or an anonymous uploader, serves script to every visitor of a page, a super admin included, which leads to a super-admin session. The default needs either a media-only account or a public upload form that shows another medium with a link or thumbnail option, so the rating is High and not Critical.
Patches
Fixed in Grav 2.2.18. The Markdown image renderer builds the element from the medium and writes any Twig opener in it as an entity, so text from a sidecar or a file name stays text when content Twig runs, while the author's own Twig in an image still runs. The `autoescape` tag is also left out of the content sandbox defaults, so sandboxed content can no longer switch output escaping off. Update the API plugin to 1.1.6 as well: it rejects `{{`, `{%` and `{#` in media metadata values. File names are covered by the core change.
Credits
Discovered by Anthropic's OSS Scanner (ANT-2026-B6SJN1LE).
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-jc8q-6vcj-4x25Las referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.
