CVE-2026-25498
JSON

8.6high

Craft has a potential authenticated Remote Code Execution via malicious attached Behavior

Severity
8.6high CVSS:4.0 by GitHub_M
Exploit likelihood
1.10% (higher than 66% of CVEs; EPSS, by FIRST)
Published
Last changed
Assigned by
GitHub_M
Also known as
GHSA-7jx7-3846-m7w7

Description

Craft is a platform for creating digital experiences. In versions 4.0.0-RC1 through 4.16.17 and 5.0.0-RC1 through 5.8.21, 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 CVE-2025-68455, affecting different endpoints through a separate code path. This vulnerability is fixed in 5.8.22.

Affected

Product or packageVersionsReported by
craftcms cms>= 5.0.0-RC1, < 5.8.22, >= 4.0.0-RC1, < 4.16.18CVE List
craftcms/cms (Packagist)from 5.0.0-RC1 before 5.8.22, from 4.0.0-RC1 before 4.16.18GitHub Advisory Database
craftcms craft_cmsfrom >4.0.0 before 4.16.18, from >5.0.0 before 5.8.22, 4.0.0, 5.0.0NVD

All scores

GitHub_M8.6high CVSS:4.0CVSS:4.0/AV:N/AC:L/AT:N/PR:H/UI:N/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N
GitHubhigh CVSS:4.0CVSS:4.0/AV:N/AC:L/AT:N/PR:H/UI:N/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N
NVD7.2high CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:U/C:H/I:H/A:H

Classification

CWE-470

SSVC (CISA-ADP): exploitation none, automatable no, technical impact total.

What each source says

CVE List

Craft is a platform for creating digital experiences. In versions 4.0.0-RC1 through 4.16.17 and 5.0.0-RC1 through 5.8.21, 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 CVE-2025-68455, affecting different endpoints through a separate code path. This vulnerability is fixed in 5.8.22.

GitHub Advisory Database

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-supplied fieldLayout POST 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:

  1. Behavior Injection: Attacker includes 'as rce' key in the fieldLayout JSON POST parameter
  2. Object Creation: Craft::createObject() processes the config through Yii2's BaseYii::configure()
  3. Behavior Attachment: Yii2's Component::__set() detects the 'as ' prefix and attaches the behavior
  4. RCE Trigger: When validate() is called on the model, EVENT_AFTER_VALIDATE fires
  5. Command Execution: AttributeTypecastBehavior calls the configured typecast function (ConsoleProcessus::execute) with the uid attribute 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:

ControllerActionPermission Required
TagsControlleractionSaveTagGroup()Admin
CategoriesControlleractionSaveGroup()Admin
EntryTypesControlleractionSave()Admin
GlobalsControlleractionSaveSet()Admin
VolumesControlleractionSave()Admin
UsersControlleractionSaveUserFieldLayout()Admin
AddressesControlleractionSaveAddressFieldLayout()Admin

References


NVD (es)

Craft es una plataforma para crear experiencias digitales. En las versiones 4.0.0-RC1 hasta la 4.16.17 y 5.0.0-RC1 hasta la 5.8.21, existe una vulnerabilidad de ejecución remota de código (RCE) en Craft CMS donde la función assembleLayoutFromPost() en src/services/Fields.PHP no logra sanear los datos de configuración proporcionados por el usuario antes de pasarlos a Craft::createObject(). Esto permite a los administradores autenticados inyectar configuraciones de comportamiento maliciosas de Yii2 que ejecutan comandos de sistema arbitrarios en el servidor. Esta vulnerabilidad representa una variante sin parchear de la vulnerabilidad de inyección de comportamiento abordada en CVE-2025-68455, afectando a diferentes puntos finales a través de una ruta de código separada. Esta vulnerabilidad se corrige en la 5.8.22.

References

Related

Sources

SourceRecordLicence
CVE ListCVE-2026-25498 changed 2026-02-10CVE Terms of Use
GitHub Advisory DatabaseGHSA-7jx7-3846-m7w7 changed 2026-04-02CC-BY-4.0
NVDCVE-2026-25498 changed 2026-06-17Public domain