Skip to main content
Press slash or control plus K to focus the search. Use the arrow keys to navigate results and press enter to open a threat.
Reconnecting to live updates…

CVE-2026-31857: CWE-94: Improper Control of Generation of Code ('Code Injection') in craftcms cms

0
High
VulnerabilityCVE-2026-31857cvecve-2026-31857cwe-94
Published: Wed Mar 11 2026 (03/11/2026, 17:30:29 UTC)
Source: CVE Database V5
Vendor/Project: craftcms
Product: cms

Description

Craft is a content management system (CMS). Prior to 5.9.9 and 4.17.4, a Remote Code Execution vulnerability exists in the Craft CMS 5 conditions system. The BaseElementSelectConditionRule::getElementIds() method passes user-controlled string input through renderObjectTemplate() -- an unsandboxed Twig rendering function with escaping disabled. Any authenticated Control Panel user (including non-admin roles such as Author or Editor) can achieve full RCE by sending a crafted condition rule via standard element listing endpoints. This vulnerability requires no admin privileges, no special permissions beyond basic control panel access, and bypasses all production hardening settings (allowAdminChanges: false, devMode: false, enableTwigSandbox: true). Users should update to the patched 5.9.9 or 4.17.4 release to mitigate the issue.

AI-Powered Analysis

Machine-generated threat intelligence

AILast updated: 03/18/2026, 19:13:55 UTC

Technical Analysis

CVE-2026-31857 is a critical remote code execution vulnerability affecting Craft CMS, a popular content management system. The flaw exists in the BaseElementSelectConditionRule::getElementIds() method, which processes user input through the renderObjectTemplate() function. This function uses Twig template rendering without sandboxing and with escaping disabled, allowing user-controlled strings to be interpreted as executable code. Because the vulnerability can be triggered by any authenticated user with access to the Control Panel, including non-admin roles such as Authors or Editors, it significantly lowers the bar for exploitation. The crafted condition rule can be sent via standard element listing endpoints, enabling attackers to execute arbitrary code on the server hosting the CMS. Notably, this vulnerability bypasses common production hardening configurations like allowAdminChanges set to false, devMode disabled, and even enableTwigSandbox enabled, which normally would mitigate such risks. The affected versions include all Craft CMS releases from 4.0.0-beta.1 up to but not including 4.17.4, and from 5.0.0-RC1 up to but not including 5.9.9. The CVSS 4.0 base score is 8.1, reflecting high severity due to network attack vector, no required privileges or user interaction, and high impact on confidentiality, integrity, and availability. While no public exploits have been observed yet, the vulnerability's characteristics make it a prime target for attackers seeking to compromise CMS infrastructure. Immediate patching to the fixed versions is strongly recommended to prevent exploitation.

Potential Impact

The impact of CVE-2026-31857 is severe for organizations using affected versions of Craft CMS. Successful exploitation grants remote code execution capabilities to any authenticated user with minimal privileges, effectively allowing attackers to take full control of the CMS server environment. This can lead to unauthorized data access, data modification or deletion, deployment of malware or ransomware, lateral movement within the network, and complete system compromise. Since the vulnerability bypasses typical hardening measures, organizations relying on configuration-based mitigations are at significant risk. The breach of CMS infrastructure can also damage organizational reputation, disrupt business operations, and expose sensitive customer or internal data. Given Craft CMS's use in various industries for web content management, the threat extends to e-commerce platforms, media sites, corporate portals, and government websites, amplifying potential downstream effects.

Mitigation Recommendations

To mitigate CVE-2026-31857, organizations should immediately upgrade Craft CMS installations to version 5.9.9 or 4.17.4 or later, where the vulnerability is patched. Until patching is possible, restrict Control Panel access strictly to trusted users and minimize the number of users with any Control Panel privileges. Implement network-level access controls such as VPNs or IP whitelisting to limit exposure of the Control Panel interface. Monitor logs for unusual activity related to element listing endpoints and condition rule submissions. Disable or limit the use of custom condition rules if feasible. Employ web application firewalls (WAFs) with rules targeting suspicious Twig template usage or anomalous POST requests to the CMS backend. Regularly audit user roles and permissions to ensure least privilege principles are enforced. Finally, maintain up-to-date backups and incident response plans to quickly recover from potential compromises.

Pro Console: star threats, build custom feeds, automate alerts via Slack, email & webhooks.Upgrade to Pro

Technical Details

Data Version
5.2
Assigner Short Name
GitHub_M
Date Reserved
2026-03-09T19:02:25.011Z
Cvss Version
4.0
State
PUBLISHED

Threat ID: 69b1aa112f860ef943525d7e

Added to database: 3/11/2026, 5:44:49 PM

Last enriched: 3/18/2026, 7:13:55 PM

Last updated: 4/25/2026, 1:18:00 PM

Views: 57

Community Reviews

0 reviews

Crowdsource mitigation strategies, share intel context, and vote on the most helpful responses. Sign in to add your voice and help keep defenders ahead.

Sort by
Loading community insights…

Want to contribute mitigation steps or threat intel context? Sign in or create an account to join the community discussion.

Actions

PRO

Updates to AI analysis require Pro Console access. Upgrade inside Console → Billing.

Please log in to the Console to use AI analysis features.

Need more coverage?

Upgrade to Pro Console for AI refresh and higher limits.

For incident response and remediation, OffSeq services can help resolve threats faster.

Latest Threats

Breach by OffSeqOFFSEQFRIENDS — 25% OFF

Check if your credentials are on the dark web

Instant breach scanning across billions of leaked records. Free tier available.

Scan now
OffSeq TrainingCredly Certified

Lead Pen Test Professional

Technical5-day eLearningPECB Accredited
View courses