Grav CMS Server-Side Template Injection Vulnerability Allowing Remote Code Execution

Vulnerability

A server-side template injection vulnerability has been identified in Grav CMS versions prior to 1.8.0-beta.27. This vulnerability allows authenticated users with editor permissions to execute arbitrary code on the server, bypassing the existing security sandbox. The issue arises because the sandbox does not fully protect the Twig object, enabling manipulation through crafted Twig directives. Exploitation involves injecting directives that interact with the Twig environment, such as calling methods or accessing attributes, which can lead to unauthorized code execution.

Impact

Exploitation of this vulnerability allows for remote code execution on the server, potentially leading to a full server compromise.

Reproduction

To reproduce this vulnerability, an authenticated user with editor permissions can create or edit a page in the Grav CMS admin console. The user must inject Twig template directives that exploit the sandbox bypass. For example, the directives can be crafted to add dangerous functions to the Twig filter system, such as 'system' or 'exec', and then use these functions to execute commands on the server.

Remediation

Users are advised to update Grav CMS to version 1.8.0-beta.27 or later, where this vulnerability has been fixed.

Added: Dec 1, 2025, 10:28 PM
Updated: Dec 1, 2025, 10:28 PM

Vulnerability Rating

Custom Algorithm
spread
5.2
impact
10.0
exploitability
6.8
remediation
7.7
relevance
1.3
threat
6.4
urgency
2.9
incentive
1.7

Our algorithm analyzes dozens of metrics to generate these 8 key vulnerability categories, which are then combined to calculate the overall risk score.