Summary
Craft CMS contains an incomplete protection boundary that allows an authenticated, low-privilege control panel user with limited edit permissions to reach an unsandboxed Twig rendering path. Under the affected configuration and request flow, attacker-controlled template content may be processed as PHP, potentially resulting in arbitrary code execution and full server compromise.
Affected context
The vulnerability occurs in Craft CMS control panel request handling when a user can edit at least one supported element type and influence a redirect-related parameter. A token-generation behavior that does not bind HMAC values to parameter names can allow a token created for one parameter to be replayed in another request context, reaching an unsandboxed object-template rendering sink. Exploitability depends on authenticated control panel access, applicable permissions, and the vulnerable request flow being available.
Exploit preconditions
- Attack surface: Authenticated Craft CMS control panel functionality
- Required access: A low-privilege control panel account with edit rights for at least one element type
- Trigger point: Processing of a crafted redirect POST parameter that reaches object-template rendering
- Why exploitation is possible: HMAC tokens are not sufficiently bound to parameter names, while the reached rendering sink remains unsandboxed and can process attacker-controlled template content
Why this happens
The issue combines incomplete remediation of a server-side template injection path with inadequate binding of security tokens to their intended request parameters. A token accepted across parameter contexts can be replayed to reach a rendering operation that interprets attacker-influenced Twig as executable template logic. When template rendering is not sandboxed or strictly constrained, this behavior maps to CWE-94: Improper Control of Generation of Code, because data supplied through an authenticated application workflow can influence code-generating or code-executing behavior.
Potential impact
- An attacker may execute arbitrary PHP code on the application server
- The attacker could access, alter, or delete application and customer data
- Server credentials and configuration secrets may be exposed
- The application could be used to access connected services or internal systems
- A successful compromise can lead to full server takeover
General mitigation guidance
Mitigation generally focuses on removing attacker influence from executable template contexts and strengthening the relationship between authorization tokens and request parameters.
Common defensive patterns include:
- Avoiding server-side evaluation of user-controlled templates or expressions
- Using sandboxed, allowlisted template rendering with dangerous operations disabled
- Binding integrity tokens to the exact parameter name, request purpose, session, and relevant context
- Applying authorization checks at the final rendering sink rather than relying only on earlier workflow permissions
- Restricting control panel privileges and separating content-editing permissions from administrative capabilities
- Treating redirect targets and other navigation parameters as untrusted, with strict parsing and allowlisting
- Keeping application secrets and server processes protected through least-privilege deployment controls
How teams detect issues like this
Detection approaches can include:
- Static analysis rules identifying template rendering APIs that receive request-derived or persisted content
- Code review checks for token validation that omits parameter names, purposes, or request context
- Searches for unsandboxed Twig or equivalent template evaluation reachable from control panel routes
- Dynamic testing of authorization boundaries and parameter substitution across authenticated workflows
- Web application monitoring for unusual control panel requests, repeated token reuse, unexpected redirect parameters, or template-engine errors
- Policy enforcement requiring allowlisted templates and security-token context binding before deployment

