/

CVE-2026-56382

Severity:

HIGH RISK

(7.2)

Code Injection (CWE-94) in Craft CMS Field Layout

CVE-2026-56382

Deferred

Vulnerability type

Category:

Code Injection

CWE:

CWE-94

Impact:

Remote Code Execution via Authenticated Admin

Severity:

HIGH RISK

(7.2)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

Craft CMS contains a code injection issue in the field layout preview endpoint where untrusted layout configuration is processed without sanitization.

An authenticated admin can inject Yii2 event handlers into the field layout configuration, leading to arbitrary PHP code execution and disclosure of sensitive environment data.

Affected context

The vulnerability appears in Craft CMS installations using versions between 5.5.0 and 5.9.13 where the FieldsController::actionRenderCardPreview() endpoint is accessible to authenticated admin users.

It triggers when the fieldLayoutConfig POST parameter is accepted and passed to Fields::createLayout() without first cleansing or normalizing the configuration.

Environments that rely on admin accounts for content or field layout management and expose this controller in the control panel are within the affected context.

Exploit preconditions

  • Attack surface: HTTP(S) control panel endpoint handling field layout previews
  • Required access: Authenticated Craft CMS admin account with permission to manage fields/layouts
  • Trigger point: Submission of a crafted fieldLayoutConfig POST parameter to FieldsController::actionRenderCardPreview()
  • Why exploitation is possible: The layout configuration is treated as trusted and passed to Fields::createLayout() without invoking Component::cleanseConfig(), allowing injected event handler definitions (e.g., on init) to be interpreted and executed by Yii2

Why this happens

The root cause is the direct use of untrusted configuration data as executable behavior within the Yii2 component system.

By passing fieldLayoutConfig straight into Fields::createLayout() without running it through Component::cleanseConfig(), the application allows attacker-controlled keys such as on init to register event handlers that point to arbitrary PHP callables or code paths.

This aligns with CWE-94: Improper Control of Generation of Code ('Code Injection'), where user-controlled data inadvertently shapes or injects executable logic rather than being treated as inert configuration.

Potential impact

  • Execution of arbitrary PHP code within the Craft CMS application context
  • Disclosure of sensitive environment variables, including database credentials and CRAFT_SECURITY_KEY
  • Full compromise of application data and configuration
  • Lateral movement within the hosting environment, depending on server permissions
  • Tampering with content, configuration, or site behavior via injected logic

General mitigation guidance

Mitigation typically focuses on treating configuration data as untrusted and normalizing it before use in component systems.

Common defensive patterns include:

  • Applying a cleansing or normalization step (such as cleanseConfig-style routines) before passing user-supplied configuration into framework components
  • Restricting or disabling dynamic event handler definitions in data structures derived from HTTP requests
  • Separating static, developer-controlled configuration from runtime, user-provided input to avoid blending data and behavior
  • Enforcing least-privilege on admin roles and limiting who can modify complex layout or field configurations
  • Implementing server-side allowlists for permissible configuration keys and structures when constructing layouts or components

How teams detect issues like this

High-level detection approaches can focus on both code and runtime behavior:

  • Static analysis rules that flag paths where request data is passed into component or event systems without sanitization or cleansing
  • Code review checklists emphasizing review of controller actions that transform request parameters into configuration arrays or component definitions
  • Framework-level policies that prohibit dynamic event handler declarations from user-controlled input
  • Logging and monitoring of unusual layout configuration submissions or unexpected event bindings, combined with anomaly detection for suspicious PHP call stacks
  • Use of automated security review tools that recognize patterns such as user input flowing into framework event systems or dynamic code hooks

Sources

SourceLink
github.comgithub.com/craftcms/cms/security/advisories/GHSA-86vw-x4ww-x467
vulncheck.comvulncheck.com/advisories/craft-cms-remote-code-execution-via-missing-config-sanitization-in-fieldscontroller

Frequently asked

questions

It can be exploited over the network if the Craft CMS control panel is reachable and an attacker can authenticate as an admin; anonymous users cannot trigger it by default.

The issue requires an authenticated admin account with the ability to interact with field layouts or the endpoint that processes fieldLayoutConfig.

Ensure that any configuration derived from HTTP requests is cleansed or normalized before use, especially when it flows into component or event systems, and disallow event handler or callback definitions in user-controlled configuration.

Establish clear boundaries between data and executable behavior, use framework-provided sanitization hooks consistently, add code review checks for dynamic code or event registration fed by user input, and enforce secure defaults that treat configuration from requests as untrusted by default.

Find out what's already
exploitable in your codebase.