Summary
A sandbox enforcement flaw in Grav 2.0.0-rc.1 through 2.0.21 allows certain Twig dump and serialization filters to bypass content-sandbox restrictions. An authenticated user with page-edit rights may expose the merged Grav configuration, including secrets such as SMTP credentials, API tokens, webhook secrets, and cache passwords, when Twig processing is enabled.
Affected context
The issue occurs in Grav installations using the Twig content sandbox with Twig processing enabled for editable page content. The affected filters are not properly recognized as requiring sandbox enforcement because the guard checks only the global sandbox state rather than the state associated with the current template source. Grav 1.7 is not affected because it does not include the Twig content sandbox.
Exploit preconditions
- Attack surface: Editable page content processed by Twig
- Required access: An authenticated account with page-edit permissions
- Trigger point: Rendering content containing an affected dump or serialization filter
- Why exploitation is possible: The sandbox guard fails to detect the active source-level sandbox, allowing filters to inspect and render sensitive configuration data
Why this happens
The underlying bug is an authorization and sandbox-state validation failure mapped to CWE-200: Exposure of Sensitive Information. The filter protection logic queries sandbox status without providing the current template source, so it observes a global flag that is not enabled by Grav. As a result, filters capable of representing objects or configuration data remain usable in a context where sensitive application state should be restricted. The real configuration object can consequently be exposed despite facade-level path redaction.
Potential impact
- Sensitive application configuration may be disclosed
- SMTP credentials and API tokens could be exposed
- Webhook secrets may be revealed
- Cache backend passwords could be disclosed
- Attackers could use recovered secrets for unauthorized access or lateral movement
- Additional application and infrastructure information may be leaked
General mitigation guidance
Mitigation generally focuses on ensuring that all data-inspection and serialization filters honor the active template sandbox.
Common defensive patterns include:
- Registering sensitive filters with explicit sandbox-enforcement metadata
- Passing source-specific sandbox context when checking filter permissions
- Disabling Twig processing for content authors who do not require it
- Applying strict allowlists for filters available in user-editable content
- Reducing the sensitivity and privileges of credentials stored in application configuration
- Preventing secrets from being exposed through generic object representations
- Rotating credentials if configuration disclosure may have occurred
How teams detect issues like this
Organizations can look for this class of issue through:
- Static analysis of Twig extension registration and sandbox metadata
- Code review checks for filter guards that rely only on global sandbox state
- Tests confirming that restricted filters remain blocked in source-level sandbox contexts
- Content and access-policy reviews for users allowed to edit Twig-enabled pages
- Monitoring rendered page content and application logs for unusual configuration-dump expressions
- Secret-scanning and configuration-monitoring controls for credentials appearing in rendered output
Automated security review tools may help identify unrestricted serialization filters and missing sandbox enforcement.

