GHSA-M2MR-HHJJ-P3V2
Anonymous visitors can read any server file through a public form upload
Texto original en inglés · Ver en español
Ciclo de vida de la vulnerabilidad
| Fecha | Fase | Evento | Detalle |
|---|---|---|---|
| Divulgación | Publicada | GHSA-M2MR-HHJJ-P3V2 divulgada | |
| Monitoreo | Detectada | Ingresó al índice | |
| Monitoreo | Verificada | Última verificación contra las fuentes |
Summary
An anonymous visitor can read any file the web server user can read, as long as its name has an extension, by uploading two image-named files through a public Grav form and then requesting an ordinary media URL. Files reachable this way include `user/accounts/admin.yaml` with the super admin's password hash, `user/config/security-private.php` and the API plugin's token signing key, and the last of these is enough to forge a super-admin API token. The only precondition is one public Form plugin form that stores uploads at the plugin's default destination (the page folder). The form does not need a file field, so an ordinary contact form qualifies. Grav's own packages (grav, grav-admin and the default skeleton) ship no page with a form, so a site is only exposed if a form was added to it, which is common for contact and signup pages. On sites without such a form the same read is available to any account with `api.media.write`.
Affected versions
Grav 2.x from 2.0.0 up to and including 2.2.17, and Grav 1.7 up to and including 1.7.53.6. The loose sidecar handling dates from 2015 (first released in 0.9.21), so older unsupported lines are affected as well.
Details
Two gaps in the core media loader combine into the file read. First, a media folder treats any file named `<file>.meta.<anything>` as the YAML sidecar of `<file>`, whatever the final extension is. The upload filters only block sidecars ending in `.yaml`, so `me.png.meta.png` passes as an ordinary image upload while core parses it as metadata for `me.png`. Second, when core merges a sidecar over the medium it does not reserve any keys, so a `filepath:` line in the sidecar replaces the path core recorded for the medium. The page then serves that path for the medium's URL, and the `.htaccess` deny rules do not apply because PHP opens the file itself.
The attack uses a public form (for example `/apply`) and needs no account. The visitor attaches two files: `me.png`, any picture, and `me.png.meta.png`, whose only content is the line `filepath: user/accounts/admin.yaml`. The Form plugin accepts both, because its default destination is the page folder and its default `accept` is `image/*`. It also accepts them for a field name the form never defined, which is why a form with only text fields works. After the form is submitted and the page tree is re-scanned (two seconds by default), a plain `GET /apply/me.png` returns the account file byte for byte, while a direct request for `/user/accounts/admin.yaml` is refused with 403. Relative paths resolve against the Grav root, so the attacker does not need to know where the site is installed, and absolute paths work as well. A target without an extension fails with a 500 instead of being served. A look-alike sidecar filled with non-YAML bytes instead makes the page and its media URLs answer 500 until the file is removed.
The same chain is reachable through the API plugin's media upload by an account holding `api.media.write`. Grav 1.7.53.6 has identical code and was confirmed to be affected. On 1.7 the page cache is not invalidated by newly added image files, so the read begins at the next cache rebuild (a page save, a cache clear or an update) rather than after two seconds.
Impact
The attacker is anonymous and needs nothing but a public form on a default configuration. The result is disclosure of the account files and operator secrets that the web server rules keep private. The password hash and the site key allow offline attacks, and the API signing secret allows an attacker to sign a token for the super admin, which is full control of the site. This is rated Critical because it crosses from anonymous visitor to administrator-equivalent access without any victim interaction or non-default setting.
Patches
Fixed in Grav 2.2.18 and 1.7.53.7. A `.meta.yaml` sidecar can no longer override the keys that say which file a medium is and where it is served from (`filepath`, `path`, `filename`, `basename`, `extension`, `url`, `type`, `mime`, `size`, `modified`, `thumb`, `thumbnails` and `media`), and a file counts as a sidecar only when the part after `.meta.` is exactly `yaml`, so `.meta.<other extension>` files are ordinary media. The core fix alone closes the file read. Update the Form plugin to 9.1.38 as well: it accepts an upload only for a file field the form declares (or one a plugin has set up through `onFormUploadSettings`), so a form without a file field, such as an ordinary contact form, no longer takes uploads.
Workarounds
Set `plugins.form.files.random_name: true`, which removes the `.meta.` part from stored upload names, or point `plugins.form.files.destination` (or the form's own `destination`) at a folder outside the page folder. Neither helps against the `api.media.write` route, which only affects sites that hand that permission to untrusted accounts.
Credits
Discovered by Anthropic's OSS Scanner (ANT-2026-X8T29AR1).
Rangos afectados
Estado del parche por paquete
| Paquete / producto | Estado | Corregida en | Desde divulgación | Última versión |
|---|---|---|---|---|
Packagistgetgrav/grav |
Corregida | 1.7.53.7, 2.2.18 | — | — |
1.7.53.72.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-m2mr-hhjj-p3v2Las referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.
