Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.
Sources: National Vulnerability Database, CISA KEV, Exploit-DB
CVE-2026-112773 Overview
Craft CMS versions 5.0.0 through 5.10.x contain a remote code execution vulnerability in the Twig templating sandbox. Authenticated Control Panel users can escape the sandbox by passing uncleansed criteria to the getNext, getPrev, or getOwners element query methods. Attackers inject Yii framework as or on configuration keys to attach malicious event handlers. These handlers execute arbitrary code as the web server user when the element query runs. The flaw is tracked as CWE-94: Improper Control of Generation of Code and affects installations of Craft CMS before version 5.11.0.
Critical Impact
Authenticated Control Panel users can achieve code execution as the web user, compromising site integrity, stored data, and underlying server resources.
Affected Products
- Craft CMS 5.0.0 through 5.10.x
- Craft CMS Control Panel (Twig sandbox component)
- Element query methods: getNext, getPrev, getOwners
Discovery Timeline
- 2026-10-19 - CVE-2026-112773 published to NVD
- 2026-10-19 - Last updated in NVD database
Technical Details for CVE-2026-112773
Vulnerability Analysis
Craft CMS uses a hardened Twig sandbox to limit what Control Panel users can execute inside templates. The sandbox restricts dangerous functions, properties, and method calls on exposed objects. The element query API exposes getNext, getPrev, and getOwners methods that accept a criteria argument. Craft passes this criteria to the underlying Yii ActiveQuery without cleansing framework-reserved configuration keys. Yii treats as and on keys in a configuration array as behavior and event handler bindings. An attacker can attach a behavior or an inline event handler closure that invokes arbitrary PHP when the query executes. The result is code execution outside the Twig sandbox boundary.
Root Cause
The root cause is missing input filtering on criteria arrays supplied through sandboxed Twig templates. Craft trusted the criteria structure that reached getNext, getPrev, and getOwners, assuming the sandbox blocked dangerous constructs upstream. Because Yii consumes as and on keys as object configuration metadata, these keys bypassed the sandbox entirely and reached the framework's reflection machinery.
Attack Vector
Exploitation requires an authenticated account with Control Panel access and the ability to author or edit Twig templates. The attacker crafts a template fragment that calls an exposed element query method with a criteria array containing an as or on key. The injected handler executes PHP when the element query is evaluated. The payload runs as the PHP-FPM or web server user, inheriting file system and database permissions.
See the Craft CMS GitHub Security Advisory and the VulnCheck advisory for
technical reproduction details:
- https://github.com/craftcms/cms/security/advisories/GHSA-wr79-9v6x-5rfq
- https://www.vulncheck.com/advisories/craft-cms-5.0.0-before-5.11.0-rce-via-twig-sandbox-behavior-injection
Stop Remote Code Execution Before It Runs
Singularity™ Endpoint detects and blocks exploit attempts at machine speed, including zero-days and novel attack techniques.
Stop Exploit AttemptsDetection Methods for CVE-2026-112773
Indicators of Compromise
- Twig templates or saved Control Panel fields containing the strings as or on as keys within arrays passed to getNext, getPrev, or getOwners.
- Unexpected child processes spawned by the PHP-FPM or web server process, especially shells or interpreters.
- New or modified PHP files in web-writable directories such as web/, storage/, or template roots after Control Panel activity.
- Outbound network connections from the web server to unfamiliar hosts shortly after a Control Panel edit.
Detection Strategies
- Audit all stored Twig templates and dynamic field configurations for getNext, getPrev, and getOwners calls, flagging any that pass array literals with as or on keys.
- Correlate Craft CMS Control Panel audit logs with web server access logs to identify authenticated template edits followed by anomalous process execution.
- Alert on PHP processes invoking system, exec, passthru, proc_open, or shell_exec on hosts running Craft CMS.
Monitoring Recommendations
- Enable Craft CMS audit logging and ship logs to a centralized SIEM or data lake for query and retention.
- Monitor file integrity on template directories, plugin paths, and vendor/craftcms/ with alerts for unauthorized changes.
- Track Control Panel authentication events, especially administrator role changes and template permission grants.
How to Mitigate CVE-2026-112773
Immediate Actions Required
- Upgrade Craft CMS to version 5.11.0 or later immediately on all production and staging environments.
- Rotate Control Panel user credentials and API tokens after patching to invalidate any attacker-held sessions.
- Review Control Panel user accounts and revoke template or Twig editing permissions from users who do not require them.
- Inspect templates, entries, and settings for the exploitation patterns described above before restoring normal operations.
Patch Information
Craft CMS 5.11.0 removes the ability to pass as and on keys through sandboxed element query criteria. Review the Craft CMS GitHub Security Advisory GHSA-wr79-9v6x-5rfq and the VulnCheck advisory for upgrade guidance.
Workarounds
- Restrict Control Panel access to trusted administrators and remove Twig template editing permissions from lower-privileged roles until the patch is applied.
- Place the Control Panel behind a VPN, IP allowlist, or reverse proxy with strict authentication to limit exposure.
- Enforce multi-factor authentication for all Control Panel accounts to reduce credential-based access paths.
# Upgrade Craft CMS via Composer
composer require craftcms/cms:^5.11.0 --update-with-dependencies
php craft migrate/all --interactive=0
php craft clear-caches/all
Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.
Sources: National Vulnerability Database, CISA KEV, Exploit-DB

