CVE-2026-31857 CraftCMS has an RCE vulnerability via relational conditionals in the control panel

High 8.1 Published Updated

Authenticated Craft CMS users can achieve remote code execution via unsandboxed Twig rendering in condition rules, bypassing security settings.

Exploited in the wild
Not known
Login needed
Not needed
Attackable
Over the internet
Victim action needed
Not needed
Fix
Available

What is CVE-2026-31857?

CVE-2026-31857 is a high-severity code injection vulnerability in Craftcms Craft Cms, published on 11 Mar 2026. An attacker can exploit it over the internet without logging in, with no action from the victim.

Official 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.

Weakness: CWE-94

Which versions are affected by CVE-2026-31857?

4 open source packages ship an affected version, including craftcms/cms. It affects 1 product.

PackageAffectedFixed in
craftcms/cms PackagistFrom 4.0.0-beta.14.17.4
craftcms/cms PackagistFrom 4.0.0-beta.14.17.4
craftcms/cms PackagistFrom 5.0.0-RC15.9.9
craftcms/cms PackagistFrom 5.0.0-RC15.9.9

Products include Craftcms Craft Cms.

How do I fix CVE-2026-31857?

Upgrade craftcms/cms to a fixed version for your release line: 4.17.4 or 5.9.9.

Upgrade, and never evaluate templates, expressions or code built from user input. More about Code injection.

Is CVE-2026-31857 being exploited?

There is no known exploitation of CVE-2026-31857 in the wild and no public exploit code.

Public exploit code: 5 proofs of concept on GitHub.

All Craftcms Craft Cms vulnerabilities

Sources

Also known as GHSA-fp5j-j7j4-mcxc.

Is CVE-2026-31857 in your software?

Upload an SBOM and sbomify checks it against every vulnerability here, every day.

Check your SBOMs for free