GHSA-3RQP-8H7G-XXV8
API plugin: publisher with media upload rights can write theme templates and run code on the server
Ciclo de vida de la vulnerabilidad
| Fecha | Fase | Evento | Detalle |
|---|---|---|---|
| Divulgación | Publicada | GHSA-3RQP-8H7G-XXV8 divulgada | |
| Monitoreo | Detectada | Ingresó al índice | |
| Monitoreo | Verificada | Última verificación contra las fuentes |
Summary
A publisher account with `api.media.write` and `api.pages.write` can write files into the active theme's Twig template folder through the API plugin's `POST /api/v1/blueprint-upload` endpoint, then include that file from sandboxed Twig it authors. File templates are trusted by design, so the included file renders outside the Twig content sandbox and can run commands on the server as the web-server user.
Affected versions
`getgrav/grav-plugin-api` 1.0.0 through 1.1.3. Grav 1.7 is not affected (it has no API plugin and no content sandbox).
Details
`BlueprintUploadController::upload()` checks only `api.media.write`. The caller chooses the `destination` and `scope`, and the path resolver accepts any stream under `user/`, including `theme://templates`, `themes://<theme>/templates` and `plugins://<plugin>/templates`. `DELETE /api/v1/blueprint-upload` has the same reach, so the same account can also delete theme and plugin template files.
The original report focused on file names such as `rce.twig%20` and `rce.twig ` slipping past the extension denylist. That bypass is real, but it is not what makes the attack work: Twig's `include` ignores the file extension, so a plain `payload.txt` written into the templates folder is just as includable. Themes can also register other folders as Twig paths (quark2 registers its `images` folder as the `@images` namespace), so a template-folder rule alone is not enough. The fix covers every theme and plugin folder, and tightens file-name checks separately.
The report's trigger (a page body with `{% include %}`) needs Twig processing on the page, which a publisher without `admin.pages_twig` cannot turn on by default. We confirmed a trigger that does work with publisher rights on a 2.2.15 install running the Form plugin: a form `process: message` action in the page frontmatter, which the Form plugin renders as sandboxed Twig, and which can `include` the uploaded file. `GravSourcePolicy::isTrusted()` treats file-backed templates as trusted on purpose (content is allowed to include theme partials); the defect is that a publisher could put a file there.
Impact
A publisher (a page editor with media upload rights, with no admin, config, user or scheduler permissions) can run code on the server. From there they can read the API signing secret and password hashes, create a super-admin account, or change site files. Unauthenticated exploitation is not possible.
Patches
Fixed in `getgrav/grav-plugin-api` 1.1.4. Uploads into and deletes from theme and plugin folders through this endpoint now require `api.config.write` (the permission that edits theme and plugin settings), and Twig template folders and any location outside `user/` require super-admin access. File names ending in a space or dot, or containing control or invisible formatting characters, are refused in both the settings-field and page-media upload paths.
Credits
Reported by @sagarbanwa.
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-plugin-api |
Corregida | 1.1.4 | — | — |
1.1.4Arsenal 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-3rqp-8h7g-xxv8Las referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.
