{"id":"CVE-2026-61450","aliases":["CVE-2026-61450","GHSA-mc5q-6hpj-rp7j"],"related":["CVE-2026-61842"],"kind":"vulnerability","state":"published","title":"Grav before 2.0.2 Config Exfiltration via offsetGet Filter","summary":"Grav before 2.0.2 contains a Twig sandbox bypass that allows a page author (any admin.pages user, or anyone able to write to user/pages) to exfiltrate configuration secrets. Although the sandbox replaces the 'config' variable with a redacted facade and strips Config::get/toArray from the method allowlist, the raw container remains accessible via the allow-listed grav.offsetGet('config'), which returns the real Config object. Allow-listed object-dumping filters (json_encode, print_r, yaml_encode) then serialize that object at the PHP level without invoking the sandbox method gate, exposing the full config tree including plugin secrets such as SMTP credentials, API keys, and plugin DB credentials. This is an incomplete fix for GHSA-j274-39qw-32c9.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"Grav before 2.0.2 contains a Twig sandbox bypass that allows a page author (any admin.pages user, or anyone able to write to user/pages) to exfiltrate configuration secrets. Although the sandbox replaces the 'config' variable with a redacted facade and strips Config::get/toArray from the method allowlist, the raw container remains accessible via the allow-listed grav.offsetGet('config'), which returns the real Config object. Allow-listed object-dumping filters (json_encode, print_r, yaml_encode) then serialize that object at the PHP level without invoking the sandbox method gate, exposing the full config tree including plugin secrets such as SMTP credentials, API keys, and plugin DB credentials. This is an incomplete fix for GHSA-j274-39qw-32c9.","source":"cvelist"},{"lang":"en","text":"### Summary\n\nThe Twig content sandbox replaces `config` with the redacted `SandboxConfig` facade and strips `Config::get`/`toArray` from the method allowlist (GHSA-j274-39qw-32c9), so editor content can't read config secrets via `config`. That's bypassable: `grav` is the raw container, `offsetget` is allow-listed on it, so `grav.offsetGet('config')` returns the real `Config`. The allow-listed filters `json_encode`/`print_r`/`yaml_encode` then serialize it at the PHP level, never hitting the sandbox method gate, dumping the whole config tree including every `plugins.*` secret (SMTP creds, API keys, plugin DB creds). Incomplete fix for GHSA-j274-39qw-32c9. `security.salt` does not leak (it lives outside config).\n\n### Details\n\nThe documented path is blocked: `config` is the `SandboxConfig` facade (`Twig.php:660`) and the raw `Config`/`Data` method entries are stripped when `config_access` is false, so `{{ config.get(...) }}` returns the default and `{{ grav.offsetGet('config').get(...) }}` raises `SecurityNotAllowedMethodError`.\n\nThe bypass uses two allow-listed primitives the redaction doesn't cover:\n\n1. `grav.offsetGet('config')` returns the raw `Config`. The `SandboxConfig` facade replaces only the `config` variable, not `grav['config']`; `offsetget` is allow-listed on `Grav\\Common\\Grav` in `system/config/security.yaml`.\n2. `json_encode`/`print_r`/`yaml_encode` serialize the object inside the filter and never call `GravSecurityPolicy::checkMethodAllowed` (`GravSecurityPolicy.php:65`), so the stripped methods don't matter.\n\nBug class: object-dumping filters bypass the sandbox member gate. The same dump reaches `page`/`pages`/`uri`/`user` via their allow-listed accessors; `config` is the secret-bearing target.\n\nReachable below the publisher-Twig opt-in: a `_`-prefixed slug is modular (`Page.php:228`), and `Page::content()` sets `$process_twig = $scan_twig_xss || $this->modularTwig()` (`Page.php:816`), so a modular child's body Twig is sandboxed-rendered even with `twig_content.process_enabled` false (the default), while `$scan_twig_xss` stays false so the render-time XSS scan (GHSA-2c4f-86xc-cr74) is skipped. Any `admin.pages` author (or filesystem write to `user/pages`) exfiltrates config on a stock install. On a regular `process.twig` page the whole-tree dump trips the XSS scan and is blanked, but a targeted `split`/`slice` extraction of one subtree is XSS-clean and survives.\n\n### PoC\n\nSandboxed render, `config_access` default false. First two lines show the gate holding, third is the bypass:\n\n```twig\n{{ config.get('plugins.email.mailer.smtp.password', 'DENIED') }}\n{# => DENIED #}\n{{ grav.offsetGet('config').get('plugins.email.mailer.smtp.password') }}\n{# => SecurityNotAllowedMethodError 'get' #}\n{{ grav.offsetGet('config')|json_encode }}\n{# => {...,\"plugins\":{\"email\":{\"mailer\":{\"smtp\":{\"password\":\"CANARY...\"}}}},...} #}\n```\n\nStock-install reproduction (no `user/config/security.yaml`):\n\n```yaml\n# user/config/plugins/email.yaml  -- decoy secret\nmailer: { smtp: { password: CANARY_SMTP_PW_8b3f1 } }\n```\n\n```\n# user/pages/70.parent/default.md\n---\ntitle: Parent\ncontent: { items: '@self.modular' }\ntemplate: modular\n---\n```\n\n```twig\n{# user/pages/70.parent/_secret/default.md #}\n---\ntitle: Secret\ntemplate: modular/text\n---\n{{ grav.offsetGet('config')|json_encode }}\n```\n\n```bash\ncurl -s http://localhost/parent   # body contains CANARY_SMTP_PW_8b3f1\n```\n\n`logs/security.log` shows no sandbox block and no XSS scan for the route. Verified on Grav 2.0.1 (6f619f0ae), PHP 8.4.22, Twig 3.26.1-DEV.\n\n### Impact\n\nA page author (`admin.pages`, no admin/super) reads the entire config tree: plugin SMTP credentials, API keys, plugin DB credentials. Read-only. Default install; the modular path needs no Twig opt-in.\n\n### Fix\n\n`system/config/security.yaml`: drop `offsetget` (and `__get`) from `twig_sandbox.allowed_methods` for `Grav\\Common\\Grav` -- the legit uses are `theme`/`getversion`; `offsetget` is the raw-container reach. Closes the demonstrated path.\n\nSandbox-wide: make `json_encode`/`print_r`/`yaml_encode`/`string` refuse non-allow-listed objects when `$env->isSandboxed()` (mirror the Closure-only guard Twig applies to `map`/`filter`/`reduce`). Closes the class for `page`/`pages`/`uri`/`user` too.","format":"markdown","source":"ghsa"},{"lang":"es","text":"Grav anterior a la versión 2.0.2 contiene un bypass de sandbox de Twig que permite a un autor de página (cualquier usuario de admin.pages, o cualquiera con capacidad de escribir en user/pages) exfiltrar secretos de configuración. Aunque el sandbox reemplaza la variable ’config’ con una fachada redactada y elimina Config::get/toArray de la lista de métodos permitidos, el contenedor crudo permanece accesible a través de grav.offsetGet(’config’), incluido en la lista de permitidos, que devuelve el objeto Config real. Los filtros de volcado de objetos permitidos en la lista (json_encode, print_r, yaml_encode) luego serializan ese objeto a nivel de PHP sin invocar la puerta de método del sandbox, exponiendo el árbol de configuración completo, incluyendo secretos de plugins como credenciales SMTP, claves de API y credenciales de base de datos de plugins. Esta es una solución incompleta para GHSA-j274-39qw-32c9.","source":"nvd"}],"published":"2026-07-10T13:58:08.307Z","modified":"2026-10-25T15:10:00.147Z","severity":{"scorer":"VulnCheck","scheme":"CVSS:4.0","vector":"CVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:N/VC:H/VI:N/VA:N/SC:N/SI:N/SA:N","score":7.1,"rating":"HIGH"},"severities":[{"scorer":"VulnCheck","scheme":"CVSS:4.0","vector":"CVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:N/VC:H/VI:N/VA:N/SC:N/SI:N/SA:N","score":7.1,"rating":"HIGH"},{"scorer":"VulnCheck","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:N/A:N","score":6.5,"rating":"MEDIUM"},{"scorer":"GitHub","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:N/A:N","score":6.5,"rating":"MEDIUM"}],"cwes":["CWE-94","CWE-200"],"affected":[{"ranges":[{"type":"semver","introduced":"0","fixed":"2.0.2","status":"affected"},{"type":"semver","version":"2.0.2","status":"unaffected"}],"vendor":"getgrav","product":"grav","source":"cvelist"},{"ranges":[{"type":"ecosystem","introduced":"0","status":"affected","fixed":"2.0.2"}],"ecosystem":"Packagist","package":"getgrav/grav","purl":"pkg:composer/getgrav/grav","source":"ghsa"}],"references":[{"url":"https://github.com/getgrav/grav/security/advisories/GHSA-mc5q-6hpj-rp7j","tags":["exploit","vendor-advisory","web"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://www.vulncheck.com/advisories/grav-before-config-exfiltration-via-offsetget-filter","tags":["third-party-advisory"],"sources":["cvelist","nvd"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2026-61842","tags":["advisory"],"sources":["ghsa"]},{"url":"https://github.com/getgrav/grav/commit/7efe70574e4cf01a251318478c13673029e93eb6","tags":["web"],"sources":["ghsa"]},{"url":"https://github.com/getgrav/grav","tags":["package"],"sources":["ghsa"]},{"url":"https://github.com/getgrav/grav/releases/tag/2.0.2","tags":["web"],"sources":["ghsa"]}],"credits":["iliaal"],"assigner":"VulnCheck","ssvc":{"scorer":"CISA-ADP","exploitation":"poc","automatable":"no","technicalImpact":"partial","date":"2026-07-10T15:46:11.337Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2026-61450","url":"https://www.cve.org/CVERecord?id=CVE-2026-61450","licence":"CVE Terms of Use","modified":"2026-10-08T15:23:35.167Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-mc5q-6hpj-rp7j","url":"https://github.com/advisories/GHSA-mc5q-6hpj-rp7j","licence":"CC-BY-4.0","modified":"2026-09-02T21:45:09.883Z"},{"source":"nvd","name":"NVD","id":"CVE-2026-61450","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-61450","licence":"Public domain","modified":"2026-10-25T15:10:00.147Z"}],"updatedAt":"2026-11-25T22:59:27.636Z","epss":{"score":0.05421,"percentile":0.92877,"date":"2026-12-01T12:00:22.000Z"}}