GHSA-8RHF-56H6-J77W
Publishers can read any server file by abusing allowed Twig sandbox calls
Texto original en inglés · Ver en español
Ciclo de vida de la vulnerabilidad
| Fecha | Fase | Evento | Detalle |
|---|---|---|---|
| Divulgación | Publicada | GHSA-8RHF-56H6-J77W divulgada | |
| Monitoreo | Detectada | Ingresó al índice | |
| Monitoreo | Verificada | Última verificación contra las fuentes |
Summary
Grav's Twig content sandbox restricts what page content can call, but it checks callable names only, not what a call does to the object it is given. Two entries on the allowlist write to objects that sandboxed content can reach. Using either, a page editor (publisher) makes the site print any file the web server user can read into a public page, including account files, the site's private keys and the API plugin's signing secret, which leads to a forged super-admin token.
Affected versions
Grav 2.x from 2.0.0 up to and including 2.2.17. Both entries have been on the allowlist since the sandbox arrived in 2.0.0-beta.2. Grav 1.7 has no Twig sandbox and is not affected.
Details
`array_key_value()` (ANT-2026-FV1GDO30). The function is meant to extend a plain array. It tests `empty($current_array)`, which is false for any object, and then assigns `$current_array[$key] = $val`. On an `ArrayAccess` object that assignment is an implicit `offsetSet()` call the sandbox policy never sees. Page content passes the shared `assets` service as the array and replaces its `collections` property. The theme's later `addCss('theme://css/custom.css')` call then inlines any readable file into the page, or bundles it into a static `/assets/<md5>.js` file that outlives the page. The reproducer shows the admin hash and the HMAC key inside a `<style>` element. The same primitive can define entries on the `grav` container.
Page accessors (ANT-2026-NCD1TUMY). Getter and setter accessors on page objects (`function x($var = null)`) are allowlisted by name, and the policy cannot tell a call with an argument from a plain getter. `filePath($var)` repoints a page object at another file, and the page's `content` is then read lazily from the new location. The reproducer renders `security-private.php` and `api-private.php` byte for byte and a forged token built from them is then accepted as `admin` with `super_admin = True`. Only regular pages are affected, which is the default, because Flex pages throw on these setters. The same allowlist row also has weaker siblings: `header($var)` can park objects in the header so that theme variable helpers expose the private configuration, `metadata($var)` stores unescaped `<meta>` content so a `<script>` element can reach `<head>`, and `media($var)`, `content($var)` and `id($var)` write to other pages' caches.
Impact
A publisher reads any file the PHP user can read and then forges a super-admin API token, so a page-editing account becomes full control of the site. The attacker needs page edit rights.
Patches
Fixed in Grav 2.2.18. `array_key_value()` only extends real arrays (given an object it returns a new array and leaves the object unchanged), and `path` and `filepath` are removed from the page accessor allowlist, so sandboxed content can no longer repoint a page at another file. The page setters that stay on the allowlist are limited to changes inside the page object: `header()` keeps plain data only (regular and Flex pages), the Flex `route()` setter takes a string only, `metadata()` escapes the content it is given as the getter does, `media()` no longer writes the shared media cache, and media or content set in memory gets an id the pages index never gives a page. The sandbox still checks the name of a call and not its arguments, so accessors that stay on the allowlist are not refused when called with one. Operators should clear the `assets/` folder after upgrading, because bundles written by an attack persist there. Site configuration that re-adds `path` or `filepath` through `allowed_methods` reopens the read and should be removed.
Credits
Discovered by Anthropic's OSS Scanner (ANT-2026-FV1GDO30, ANT-2026-NCD1TUMY).
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-8rhf-56h6-j77wLas referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.
