Craft CMS Authenticated Remote Code Execution via Malicious Attached Behavior
A remote code execution vulnerability exists in Craft CMS versions 5.6.0 through 5.9.12, where any authenticated user with control panel access can exploit the vulnerability by injecting malicious behavior via the `fieldLayouts` parameter in `ElementIndexesController::actionFilterHud()` due to the unsanitized parameter being passed to `FieldLayout::createFromConfig()`.
Craft CMS versions 5.6.0 through 5.9.12 are susceptible to a remote code execution (RCE) vulnerability (CVE-2026-33157) that bypasses previous security measures implemented to prevent similar attacks. The vulnerability stems from the ElementIndexesController::actionFilterHud() function, where the fieldLayouts parameter is passed directly to FieldLayout::createFromConfig() without proper sanitization. Any authenticated user with control panel access (accessCp permission) can exploit this flaw by injecting malicious behaviors into the fieldLayouts configuration. This oversight allows attackers to execute arbitrary code on the server, potentially leading to complete system compromise. Defenders need to implement mitigations to detect and prevent exploitation of this vulnerability.
Attack Chain
- An authenticated user with control panel access crafts a malicious HTTP request.
- The request includes a
fieldLayoutsarray with a configuration containing"as <name>"prefixed keys within the request body to the/admin/element-indexes/filter-hudendpoint. ElementIndexesController::actionFilterHud()receives thefieldLayoutsparameter.- The
fieldLayoutsparameter is passed toFieldLayout::createFromConfig($config)without sanitization. FieldLayout::createFromConfig($config)invokesModel::__construct($config), which processes each key in the configuration.- The
"as rce"key triggersComponent::__set("as rce", $value), which leads to the instantiation ofAttributeTypecastBehaviorand its attachment to the FieldLayout viaYii::createObject($value). - An
"on *"key registers a wildcard event handler. Subsequently,parent::__construct()is called followed byinit()->setTabs([])->getAvailableNativeFields()->trigger(EVENT_DEFINE_NATIVE_FIELDS). - The wildcard handler fires, triggering
AttributeTypecastBehavior::beforeSave()->typecastAttributes(). The vulnerability results in$this->owner->typecastBeforeSavebeing resolved viaComponent::__get()which returns the command string from the behavior’s own property, finally reachingcall_user_func([ConsoleProcessus::class, 'execute'], $command)->shell_exec($command)enabling remote code execution.
Impact
The vulnerability allows any authenticated user with control panel access to execute arbitrary code on the Craft CMS server. Successful exploitation can lead to complete system compromise, including data theft, modification, or destruction. This RCE vulnerability can have significant impacts on organizations using affected versions of Craft CMS (5.6.0 through 5.9.12).
Recommendation
- Deploy the Sigma rule to detect exploitation attempts by monitoring for HTTP requests to
/admin/element-indexes/filter-hudwith thefieldLayoutsparameter in the request body (see Sigma rule “Craft CMS RCE Attempt via ElementIndexesController”). - Apply available patches or upgrade to a non-vulnerable version of Craft CMS (versions prior to 5.6.0 or later than 5.9.12).
- Restrict access to the control panel to only trusted users with a legitimate need, reducing the attack surface.
- Review and audit existing Craft CMS configurations for any suspicious behavior or event injections.
- Monitor web server logs for unusual activity related to the
ElementIndexesControllerandFieldLayoutcomponents, focusing on POST requests containing potentially malicious configurations (see Sigma rule “Craft CMS RCE - AttributeTypecastBehavior”).
Detection coverage 2
Craft CMS RCE Attempt via ElementIndexesController
highDetects attempts to exploit the Craft CMS RCE vulnerability by monitoring for HTTP requests to the /admin/element-indexes/filter-hud endpoint with the fieldLayouts parameter in the request body.
Craft CMS RCE - AttributeTypecastBehavior
highDetects potential RCE attempts in Craft CMS by identifying requests that may trigger the AttributeTypecastBehavior, which is involved in the exploit.
Detection queries are kept inside the platform. Get full rules →