Skip to main content
Vulnerability Database/CVE-2026-112777

CVE-2026-112777: Craft CMS Twig RCE Vulnerability

CVE-2026-112777 is a remote code execution flaw in Craft CMS that exploits a case-sensitivity bypass in the Twig create function. Attackers with template rights can read secrets or write malicious files. This post explains its impact, affected versions, and mitigation steps.

Published:

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-112777 Overview

Craft CMS contains a blocklist bypass in the Twig create() function that allows authenticated attackers with template-execution rights to achieve remote code execution. The flaw affects Craft CMS 4.x before 4.18.8 and 5.x before 5.11.0. The vulnerability stems from case-sensitive class-name checks in the blocklist, while PHP class resolution is case-insensitive. Attackers can instantiate SplFileObject using a lowercase class name to read .env secrets or write a PHP file into the webroot. Control Panel administrators represent the primary threat population because they already hold template-execution privileges.

Critical Impact

Authenticated attackers with template rights can bypass the Twig create() blocklist to read sensitive files such as .env and write arbitrary PHP into the webroot, resulting in remote code execution.

Affected Products

  • Craft CMS 4.x prior to 4.18.8
  • Craft CMS 5.x prior to 5.11.0
  • Deployments exposing the Control Panel to administrator or template-author roles

Discovery Timeline

  • 2026-10-19 - CVE-2026-112777 published to the National Vulnerability Database (NVD)
  • 2026-10-20 - Last updated in NVD database

Technical Details for CVE-2026-112777

Vulnerability Analysis

Craft CMS exposes a Twig create() helper that instantiates PHP classes requested from templates. To prevent dangerous classes from being constructed, Craft maintains a blocklist of forbidden class names. The blocklist comparison runs with case-sensitive string checks, but PHP resolves class names in a case-insensitive manner. This mismatch allows an attacker to supply a variant such as splfileobject to defeat the filter while still resolving to the real SplFileObject class.

Once SplFileObject is instantiated, the attacker gains primitives for arbitrary file read and write within the web server's permission boundary. Reading .env exposes database credentials, application keys, and third-party API tokens. Writing attacker-controlled PHP into the webroot converts the file-write primitive into reliable remote code execution. The weakness is categorized as [CWE-184: Incomplete List of Disallowed Inputs].

Root Cause

The root cause is an incomplete denylist implementation inside the Twig create() wrapper. The security check normalizes neither the user-supplied class name nor the blocklist entries before comparison. Any case permutation of a forbidden class name slips past validation because PHP's class loader treats SplFileObject, splfileobject, and SPLFILEOBJECT as identical.

Attack Vector

Exploitation requires authenticated access with permission to render or edit Twig templates, which Control Panel administrators possess by default. The attacker crafts a Twig expression that calls create() with a lowercase variant of a blocked class and passes a target file path as the constructor argument. The returned object exposes read and write methods that operate against the local filesystem under the web server account. Dropping a PHP payload inside the public webroot and then requesting it over HTTP completes the chain to remote code execution. Full technical analysis is available in the GitHub Security Advisory GHSA-w643-x88w-6wcm and the VulnCheck advisory.

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 Attempts

Detection Methods for CVE-2026-112777

Indicators of Compromise

  • Twig templates or Control Panel field values containing calls to create() with class names such as splfileobject, SPLFILEOBJECT, or other case-mixed variants of blocklisted classes.
  • Unexpected .php files appearing under the public webroot, especially with recent modification timestamps and web-server ownership.
  • Access log entries requesting newly created PHP files immediately after Control Panel template edits.
  • Reads of sensitive files such as .env, config/db.php, or storage/ artifacts initiated by the PHP-FPM or web server process.

Detection Strategies

  • Audit Craft CMS template content and database-backed Twig fields for any invocation of create() referencing filesystem or reflection classes.
  • Alert on web-server processes writing .php files into document-root paths that normally serve only static assets.
  • Correlate Control Panel administrator logins with filesystem change events on the Craft installation.

Monitoring Recommendations

  • Forward Craft CMS application logs, PHP error logs, and web-server access logs to a central analytics platform for retention and correlation.
  • Enable file integrity monitoring on the webroot, vendor/, and storage/ directories to flag unauthorized writes.
  • Review Control Panel user and permission assignments regularly, and alert on new administrator role grants.

How to Mitigate CVE-2026-112777

Immediate Actions Required

  • Upgrade Craft CMS to version 4.18.8 or 5.11.0 or later without delay.
  • Restrict Control Panel access to a limited set of trusted administrators and remove unused accounts.
  • Rotate .env secrets, application keys, database credentials, and any API tokens that may have been exposed on vulnerable instances.
  • Review the webroot for unexpected .php files and investigate any matches as potential webshells.

Patch Information

Craft CMS resolved the blocklist bypass in versions 4.18.8 and 5.11.0. The fix normalizes class-name comparisons so that case variants of blocked classes are rejected consistently with PHP's resolution behavior. Upgrade details and the full patch notes are documented in the GitHub Security Advisory GHSA-w643-x88w-6wcm.

Workarounds

  • Place the Craft Control Panel behind network restrictions such as IP allowlists, VPN, or SSO-enforced reverse proxies until patching completes.
  • Remove or downgrade template-editing permissions for non-essential administrator accounts.
  • Enforce least-privilege filesystem permissions so the PHP process cannot write to the public webroot during normal operation.
bash
# Upgrade Craft CMS to a fixed release using Composer
composer require craftcms/cms:^5.11.0 --update-with-dependencies
# For the 4.x branch
composer require craftcms/cms:^4.18.8 --update-with-dependencies

# Apply pending migrations after upgrading
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

Experience the Most Advanced Cybersecurity Platform

See how the world’s most intelligent, autonomous cybersecurity platform can protect your organization today and into the future.