Summary
Craft CMS Vulnerable to potential authenticated Remote Code Execution via malicious attached Behavior
Relationship to Previously Patched Vulnerability
This vulnerability is in addition to the RCE vulnerability patched in GHSA-255j-qw47-wjh5. That advisory addressed a similar RCE vulnerability that affected two specific routes:
/index.php?p=admin%2Factions%2Ffields%2Fapply-layout-element-settings/index.php?p=admin%2Factions%2Ffields%2Frender-card-preview
This one addresses some additional endpoints that were not covered in the https://github.com/craftcms/cms/security/advisories/GHSA-255j-qw47-wjh5.
The patched vulnerability used a malicious AttributeTypecastBehavior with a wildcard event listener ("on *": "self::beforeSave") and __construct() syntax to trigger RCE via the typecastBeforeSave callback. The fix was implemented in commits:
This vulnerability follows the same attack pattern (behavior injection via "as <behavior>" syntax) but affects a different code path (assembleLayoutFromPost() in Fields.php) that was not patched in those commits. The attack vector uses typecastAfterValidate instead of typecastBeforeSave and does not require the wildcard event listener syntax, demonstrating that multiple entry points exist for this type of vulnerability.
Executive Summary
A Remote Code Execution (RCE) vulnerability exists in Craft CMS where the assembleLayoutFromPost() function in src/services/Fields.php fails to sanitize user-supplied configuration data before passing it to Craft::createObject(). This allows authenticated administrators to inject malicious Yii2 behavior configurations that execute arbitrary system commands on the server. This vulnerability represents an unpatched variant of the behavior injection vulnerability addressed in GHSA-255j-qw47-wjh5, affecting different endpoints through a separate code path.
Vulnerability Details
Attack Prerequisites
- Authentication: Admin-level access required
- Network Access: Access to admin panel (
/admin)
Location
- File:
src/services/Fields.php - Function:
assembleLayoutFromPost()(lines 1125-1143) - Root Cause: Missing
cleanseConfig()call on user-suppliedfieldLayoutPOST parameter
Vulnerable Code Path
// src/services/Fields.php:1125-1133
public function assembleLayoutFromPost(?string $namespace = null): FieldLayout
{
$paramPrefix = $namespace ? rtrim($namespace, '.') . '.' : '';
$request = Craft::$app->getRequest();
$config = JsonHelper::decode($request->getBodyParam("{$paramPrefix}fieldLayout"));
// ... additional config values added ...
$layout = $this->createLayout($config); // <-- No cleanseConfig() call!
// ...
}
// src/services/Fields.php:1089-1093
public function createLayout(array $config): FieldLayout
{
$config['class'] = FieldLayout::class;
return Craft::createObject($config); // <-- Untrusted data passed directly
}
Attack Chain
The exploitation leverages Yii2's object configuration system and behavior attachment mechanism:
- Behavior Injection: Attacker includes
'as rce'key in thefieldLayoutJSON POST parameter - Object Creation:
Craft::createObject()processes the config through Yii2'sBaseYii::configure() - Behavior Attachment: Yii2's
Component::__set()detects the'as 'prefix and attaches the behavior - RCE Trigger: When
validate()is called on the model,EVENT_AFTER_VALIDATEfires - Command Execution:
AttributeTypecastBehaviorcalls the configured typecast function (ConsoleProcessus::execute) with theuidattribute value as the command
RCE Gadget Chain
FieldLayout POST parameter
→ Craft::createObject()
→ Yii2 Component::__set() with 'as rce' key
→ AttributeTypecastBehavior attached
→ Model::validate() called
→ EVENT_AFTER_VALIDATE triggered
→ typecastAfterValidate → typecastAttributes()
→ call_user_func(['Psy\Readline\Hoa\ConsoleProcessus', 'execute'], $command)
→ Shell command execution
Affected Controllers
The assembleLayoutFromPost() function is called by multiple admin controllers:
| Controller | Action | Permission Required |
|---|---|---|
TagsController |
actionSaveTagGroup() |
Admin |
CategoriesController |
actionSaveGroup() |
Admin |
EntryTypesController |
actionSave() |
Admin |
GlobalsController |
actionSaveSet() |
Admin |
VolumesController |
actionSave() |
Admin |
UsersController |
actionSaveUserFieldLayout() |
Admin |
AddressesController |
actionSaveAddressFieldLayout() |
Admin |
References
- https://github.com/craftcms/cms/commit/395c64f0b80b507be1c862a2ec942eaacb353748
- GHSA-255j-qw47-wjh5 - Previously patched RCE vulnerability via behavior injection (affecting different endpoints)
- CVE-2024-4990 - Related vulnerability that inspired the behavior injection attack pattern
- Yii2 GHSA-gcmh-9pjj-7fp4 - Original Yii framework report (framework team declined to fix at framework level)
Impact
Affected versions
Security releases
Kodem intelligence
Severity tells you how bad this could be in the worst case. It does not tell you whether you are exposed. Exploitability and impact are functions of runtime truth: whether the vulnerable code is present, reachable, and actually executes in your application. A vulnerable package can sit in your dependency tree and never run.
Kodem, an Intelligent Application Security platform, uses runtime intelligence to reveal which vulnerabilities actually execute in production, so teams prioritize the ones that genuinely matter. Kodem's runtime-powered SCA identifies whether this CVE is reachable in your applications.
Already deployed Kodem?
See it in your environmentNew to Kodem? Get a demo →Remediation advice
craftcms/cms to 5.8.22 or later; craftcms/cms to 4.16.18 or later
Kodem Kai can prioritize this vulnerability in your dependency tree and generate a fix recommendation.
Frequently Asked Questions
- What is CVE-2026-25498? CVE-2026-25498 is a high-severity security vulnerability in craftcms/cms (composer), affecting versions >= 5.0.0-RC1, <= 5.8.21. It is fixed in 5.8.22, 4.16.18.
- Which versions of craftcms/cms are affected by CVE-2026-25498? craftcms/cms (composer) versions >= 5.0.0-RC1, <= 5.8.21 is affected.
- Is there a fix for CVE-2026-25498? Yes. CVE-2026-25498 is fixed in 5.8.22, 4.16.18. Upgrade to this version or later.
- Is CVE-2026-25498 exploitable, and should I be worried? Whether CVE-2026-25498 is exploitable in your environment depends on whether the vulnerable code is present and reachable. A CVSS score is a worst-case rating; it does not account for your specific deployment, configuration, or usage patterns. Kodem, an Intelligent Application Security platform, uses runtime intelligence to show which vulnerabilities actually execute in production, so you can focus on the ones that represent real risk. Get a demo
- What actually determines whether CVE-2026-25498 is exploitable, and how bad it is? Exploitability and impact are not fixed properties of a CVE. They depend on runtime truth: whether the vulnerable code is present, reachable, and actually executes in your application. A high CVSS score on a dependency that never runs is not the same as real risk. Kodem, an Intelligent Application Security platform, uses runtime intelligence to reveal which vulnerabilities actually execute in production, so teams prioritize the ones that genuinely matter.
- How do I fix CVE-2026-25498?
- Upgrade
craftcms/cmsto 5.8.22 or later - Upgrade
craftcms/cmsto 4.16.18 or later
- Upgrade