Listen to this Post
The vulnerability exists because the Twig content sandbox in Grav CMS improperly handles object serialization after a partial fix for GHSA-j274-39qw-32c9. The initial fix replaced the `config` variable with a `SandboxConfig` facade and stripped `Config::get` and `Config::toArray` from the method allowlist to prevent editors from reading configuration secrets. However, the sandbox does not fully isolate the underlying container. The `grav` variable, which is the raw `Grav\Common\Grav` container, still has `offsetGet` allow-listed in system/config/security.yaml. This allows an attacker to call grav.offsetGet('config'), which returns the real, unrestricted `Config` object, bypassing the facade. Furthermore, the sandbox’s method gate, GravSecurityPolicy::checkMethodAllowed, is only invoked when a method is called on an object. The vulnerability is exploited through allow-listed Twig filters like json_encode, print_r, and yaml_encode. These filters serialize the object at the PHP level without ever calling the sandbox’s method check. Consequently, the entire configuration tree, including all plugin secrets such as SMTP credentials and API keys, is dumped. The issue is reachable even when Twig content processing is disabled. Any page with a modular child (a page with a slug prefixed by an underscore) will have its body rendered with Twig sandboxing enabled via Page::modularTwig(). This path does not trigger the XSS scan, allowing the full configuration dump to be returned in the HTTP response. This gives any user with `admin.pages` permissions, or anyone with filesystem write access to user/pages, a read-only exfiltration of sensitive data on a default installation.
DailyCVE Form:
Platform: Grav CMS
Version: 2.0.1
Vulnerability: Sandbox Bypass
Severity: High
date: 2026-09-03
Prediction: Mid-September 2026
What Undercode Say:
The core of the issue is the incomplete sandbox implementation. The `config` facade is a good start, but it doesn’t protect the container itself. The allow-listed `offsetGet` method on `Grav` is the primary entry point. The real bypass is that the serialization filters operate outside the method-gate logic. From an analytics perspective, this means any object-dumping filter can be used as a vector. To demonstrate the persistence of configuration data:
Check if config contains sensitive data
php -r "print_r(json_decode(file_get_contents('user/config/plugins/email.yaml'), true));"
The exploit path is very straightforward and can be triggered via a simple HTTP request. The modular page condition is key to bypassing the XSS scan that would otherwise blank the output.
Exploit: (Educational Purposes!)
1. Create a parent page that is modular.
- Create a child page with a slug prefixed by an underscore (e.g.,
_secret). - In the child page’s content, use the bypass payload.
- Access the parent page URL to trigger the sandboxed render.
Example payload for `user/pages/70.parent/_secret/default.md`:
Secret
template: modular/text
{{ grav.offsetGet('config')|json_encode }}
Protection:
- Immediate: Drop `offsetGet` (and
__get) from `twig_sandbox.allowed_methods` for `Grav\Common\Grav` insystem/config/security.yaml. - Comprehensive: Modify the sandbox to refuse serialization of non-allow-listed objects. Specifically,
json_encode,print_r,yaml_encode, and `string` should check `$env->isSandboxed()` and reject objects that are not explicitly allowed, mirroring the guard Twig applies tomap,filter, andreduce.
Impact:
- Confidentiality: Full read access to the entire configuration tree. This exposes all plugin secrets including SMTP passwords, API keys, and database credentials.
- Scope: Default install. No special `twig_content.process_enabled` flag required.
- Privilege: `admin.pages` authors or users with filesystem write access.
- Detection: The attack does not trigger sandbox blocks or XSS scan logs, making it difficult to detect via standard logging.
🎯Let’s Practice Exploiting & Learn Patching For Free:
🎓 Live Courses & Certifications:
Join Undercode Academy for Verified Certifications
🚀 Request a Custom Project:
Secure, high-velocity infrastructure and disruptive technological engineering. Contact our engineering team for high-tier development and proprietary systems:
[email protected]
💎 Smart Architecture | 🛡️ Secure by Design | ⭐ Trusted by Thousands
Sources:
Reported By: github.com
Extra Source Hub:
Undercode

