Grav before 2.0.19 (affected versions <= 2.0.17) contains a remote code execution vulnerability in the Twig sort filter. The sortFunc wrapper in GravE...
Description
Grav before 2.0.19 (affected versions <= 2.0.17) contains a remote code execution vulnerability in the Twig sort filter. The sortFunc wrapper in GravExtension.php hardcodes Twig's isSandboxed argument to false, so unlike |map/|filter/|reduce, |sort accepts a plain function name inside the sandbox; the remaining denylist misses spl_autoload, which performs a PHP include. An authenticated user with only page-write rights (admin.pages or api.pages.write) can supply a crafted payload (e.g., via form frontmatter rendered by the Email plugin) that invokes spl_autoload through the sort filter, resulting in arbitrary PHP execution as the web server user.
AI Analyst Comment
Remediation
Apply security patches immediately for internet-facing systems. Monitor for exploitation attempts and review access logs.
Description Summary:
Grav CMS before 2.0.19 is vulnerable to remote code execution via the Twig sort filter due to an improper sandbox configuration that allows unauthorized access to the spl_autoload function.
Executive Summary:
Grav CMS versions prior to 2.0.19 contain a critical remote code execution vulnerability that allows authenticated users with page-write access to execute arbitrary PHP code.
Vulnerability Details
CVE-ID: CVE-2026-85604
Affected Software: Grav Grav CMS
Affected Versions: 0 up to (excluding) 2.0.19
Vulnerability: The vulnerability exists in the Twig sort filter where the sortFunc wrapper incorrectly disables sandboxing. This allows an authenticated user with page-write privileges to invoke the spl_autoload function, which can be leveraged to trigger arbitrary PHP code execution on the server.
Business Impact
Successful exploitation of this vulnerability permits an attacker to execute arbitrary code with the permissions of the web server user. This level of access typically results in a total compromise of the application, potential data exfiltration, and the ability to pivot into the underlying server infrastructure. With a CVSS score of 8.8, this flaw represents a high-risk security event that requires immediate attention to prevent full system takeover.
Remediation Plan
Immediate Action: Update Grav CMS to version 2.0.19 or later immediately to apply the necessary security patches and restrict the Twig sort filter functionality.
Proactive Monitoring: Review web server and application logs for suspicious entries involving Twig filter usage or unexpected file inclusion attempts.
Compensating Controls: Implement a Web Application Firewall (WAF) with rules designed to detect and block malicious payloads targeting PHP template engines or anomalous input in form frontmatter.
Exploitation Status
Public Exploit Available: Unknown
Analyst Notes: As of September 5, 2026, there is no public information indicating active exploitation or a published proof-of-concept for this vulnerability. While the flaw allows for significant impact, the requirement for authenticated page-write access serves as a partial barrier to entry.
Analyst Recommendation
Given the potential for remote code execution, this vulnerability poses a severe threat to the integrity and availability of the Grav CMS environment. Administrators must prioritize updating to version 2.0.19 as soon as possible to neutralize the risk of arbitrary code execution. Continuous monitoring of administrative actions and application logs is advised until the update is fully deployed across all instances.