GHSA-3X2V-6JQQ-7GQ8
Page editors can read secrets and run PHP through blueprint files
Texto original en inglés · Ver en español
Ciclo de vida de la vulnerabilidad
| Fecha | Fase | Evento | Detalle |
|---|---|---|---|
| Divulgación | Publicada | GHSA-3X2V-6JQQ-7GQ8 divulgada | |
| Monitoreo | Detectada | Ingresó al índice | |
| Monitoreo | Verificada | Última verificación contra las fuentes |
Summary
Grav treats a blueprint as trusted whenever it was loaded from a file, wherever that file came from. Three paths let a page editor (publisher) put attacker-chosen content into that trusted position. One reads files from the server and prints them in a public form, including the super admin's password hash and the site's private keys. The other two plant or select a YAML file as a trusted blueprint, whose dynamic fields may call any public static PHP method, which gives PHP execution as the web server user. All three need a publisher account (page write, and media write for the two code execution paths). They share a fix site in core and should be fixed together.
Affected versions
Grav 2.x from 2.0.0 up to and including 2.2.17. The uploaded-file path (selecting a page media file as the page blueprint) was introduced in Grav 2.0.15, so it affects 2.0.15 and later. The import and flash folder paths are older. Grav 1.7 contains the import resolver and the flash folder choice, but both need a publisher account, so 1.7 is not part of this advisory's patched releases.
Details
Import directive. A page-authored form can use the `import@` directive. Blueprint loading resolves it before the checks that apply to `data-*@` and `config-*@` directives, so it never consults whether the blueprint came from a page. The resolver accepts either any existing file path, or a name joined to a `context:` stream the page chooses (such as `user://accounts` or `config://`). The parsed file is embedded in the form and the Form plugin's select template prints it. Only files that parse as a YAML mapping or a single plain scalar can be read, so logs and most PHP source are out of reach. Account files, saved plugin configuration and the `*-private.php` secret files are readable. The reproducer stores one form page as `editor`, then fetches it anonymously and finds the admin's bcrypt hash and the site key in the HTML. With the API plugin installed, reading its private configuration yields the token signing secret, and a token signed with it is accepted as super admin.
Uploaded blueprint. `Blueprint::__construct()` marks a blueprint trusted when it was built from no injected items, which is every blueprint read from a file, and trusted callers skip the `Class::method` allowlist. A page's free-text `template` header is used as the blueprint name, and the loader accepts any existing path or stream URI. A publisher uploads a `.txt` file containing YAML as page media and names it as the template. Core then loads it as a trusted blueprint. The reproducer does this in one `PATCH /api/v1/pages/gallery` and then has a directive call `Installer::replaceFile()` to copy a second upload to a `.php` file in the web root. The same directive in page frontmatter is correctly refused. Flex pages reach the same loader without passing through the page loader, so the fix has to sit at file loading.
Flash folder. A form defined in page frontmatter can choose its own `form.flash_folder`. `FormFlash` writes posted data into that folder and deletes subfolders of it, and the form trait never checks whether the blueprint is trusted. A publisher points the folder at `user://blueprints/pages`, an anonymous `task=store-state` post then writes an `index.yaml` there, and the publisher opens it through the API as a trusted blueprint. The reproducer ends with an uploaded PHP file answering with the result of `6*7`. The same input also deletes any simply named folder under `user/` on `clear-state` or form completion. Deleting `user/accounts` on a site running the API plugin reopens first-run setup, which then creates a super admin for whoever calls it. This is the counterpart of GHSA-hmcx-ch82-3fv2, which sanitized the flash ids but left the folder untouched.
Impact
A publisher can read account password hashes and the site's secret keys, or run PHP as the web server user, either of which leads to a forged super-admin token or full control of the server account. The attacker needs page and media editing rights. Similar blueprint provider issues were published as GHSA-fj2p-qj2f-74v5, GHSA-7pgq-cr25-xvc8 and GHSA-f8wv-xp27-6gq7.
Patches
Fixed in Grav 2.2.18. An `import@` directive that comes from a page-authored form may now only name a blueprint under `blueprints://`, so it can no longer reach arbitrary file paths, other streams or plugin and theme contexts. A blueprint file is trusted only when it lies in a blueprint, plugin or theme folder (`blueprints://`, `plugins://` or `themes://`), so a file uploaded as page media and named as the page template is untrusted, and a page whose `template` is a stream URI or a file path gets the default blueprint. A form defined in page frontmatter always keeps its flash data in the default forms folder, because `form.flash_folder` is read only from a trusted blueprint. Custom blueprint files stored outside those folders are no longer trusted: move them into `user/blueprints` or into a folder added to the `blueprints://` stream.
Credits
Discovered by Anthropic's OSS Scanner (ANT-2026-A5ZKZZ29, ANT-2026-Z9QB16E0, ANT-2026-1AM7W8WV).
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-3x2v-6jqq-7gq8Las referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.
