The vulnerability exists because Craft CMS, which is built on the Yii framework, did not properly sanitize user-provided configuration data before using it to instantiate or configure components. An attacker with administrator privileges could send a specially crafted JSON payload to specific controller actions. This payload would abuse the Yii framework's object configuration features to attach a malicious 'Behavior' (yii\behaviors\AttributeTypecastBehavior) to a component. By subsequently triggering an event on that component, the attacker could execute arbitrary code on the server.
The analysis of the provided patches confirms this root cause. The patches consistently add calls to a Component::cleanseConfig() function in the src/controllers/FieldsController.php file. This function is used to sanitize configuration arrays received from user requests, specifically removing potentially dangerous keys like __class, __construct(), and event handlers (on *) that enable the exploit.
The vulnerable functions were identified by locating where this sanitization was added. The patches directly modify actionRenderCardPreview and the helper methods _fldComponent and _fldComponentConfig. The vulnerability report explicitly mentions the endpoint /admin/actions/fields/apply-layout-element-settings, which corresponds to an action that relies on these patched helper methods. Therefore, these functions are the points where the malicious input is processed and are the key indicators of the vulnerability being triggered.