Get a Demo

Let's Patch It!

Book a short call with one our specialists, we'll walk you through how Endor Patches work, and ask you a few questions about your environment (like your primary programming languages and repository management). We'll also send you an email right after you fill out the form, feel free to reply with any questions you have in advance!

CVE

CVE-2025-66297

Grav vulnerable to Privilege Escalation and Authenticated Remote Code Execution via Twig Injection
Back to all
CVE

CVE-2025-66297

Grav vulnerable to Privilege Escalation and Authenticated Remote Code Execution via Twig Injection

Summary

A user with admin panel access and permissions to create or edit pages in Grav CMS can enable Twig processing in the page frontmatter. By injecting malicious Twig expressions, the user can escalate their privileges to admin or execute arbitrary system commands via the scheduler API. This results in both Privilege Escalation (PE) and Remote Code Execution (RCE) vulnerabilities.

Details

Grav CMS allows Twig to be executed in page templates if enabled in admin panel (process: twig: true).

A user with publisher/editor privileges, that can create or edit pages and enable twig processing, can thereby inject arbitrary code that will execute in the context of the page render.

This enables exploitation of Grav internal APIs such as:

  • grav.user.update() and grav.user.save() for escalating the current user to super admin or admin
  • grav.scheduler.addCommand()grav.scheduler.save() and grav.scheduler.run() for code execution

The Twig sandbox is not enforced in this context, allowing full access to any backend PHP object and method in the system/src/Grav/Common directory.

PoC

Preconditions:

  • You must have access to a non-admin user with permission to create/edit pages (admin.pages access)
  • For Privilege Escalation, you also have to be logged in to the site with the same user as the admin panel.

Steps to reproduce Privilege Escalation:

  1. Login into the non-admin page (default at cms-url/login).
  2. Login to the admin panel, create or edit a page and set the Twig processing to true (Advanced -> Process: Twig: true).
  3. Inject the following payload into the page content to escalate privileges:
{% set _ = grav.user.update({
    'access': {
        'admin': {
            'login': true,
            'super': true
        }
    }
}, {}) %}
{% set _ = grav.user.save() %}
  1. Visit the edited/created page url. The logged in user is now admin. (Note: For the changes to show, you need to log out of the admin panel and relogin).

Steps to reproduce Remote Code Execution:

  1. Login to the admin panel, create or edit a page and set the Twig processing to true (Advanced -> Process: Twig: true).
  2. Inject the following payload into the page content to execute commands:
{% set _ = grav.scheduler.addCommand('curl', ['http://localhost:8000']) %}
{% set _ = grav.scheduler.save() %}
{% set _ = grav.scheduler.run() %}
  1. Visit the page to trigger the execution. The system will issue a curl request.

Impact

This vulnerability allows:

  • Privilege Escalation from any user with page editing capabilities to full admin (super) access.
  • Remote Code Execution, as the attacker can run system arbitrary commands via the scheduler API.

It affects any Grav CMS installation where users with lower privileges are allowed to create or edit pages and Twig processing is not globally disabled.

Package Versions Affected

Package Version
patch Availability
No items found.

Automatically patch vulnerabilities without upgrading

Fix Without Upgrading
Detect compatible fix
Apply safe remediation
Fix with a single pull request

CVSS Version

Severity
Base Score
CVSS Version
Score Vector
C
H
U
7.4
-
4.0
CVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:N/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N/E:P/CR:X/IR:X/AR:X/MAV:X/MAC:X/MAT:X/MPR:X/MUI:X/MVC:X/MVI:X/MVA:X/MSC:X/MSI:X/MSA:X/S:X/AU:X/R:X/V:X/RE:X/U:X
C
H
U
0
-
C
H
U
-

Related Resources

No items found.

References

https://github.com/getgrav/grav/security/advisories/GHSA-858q-77wx-hhx6, https://nvd.nist.gov/vuln/detail/CVE-2025-66297, https://github.com/getgrav/grav/commit/e37259527d9c1deb6200f8967197a9fa587c6458, https://github.com/getgrav/grav

Severity

8.8

CVSS Score
0
10

Basic Information

Ecosystem
Base CVSS
8.8
EPSS Probability
0.00345%
EPSS Percentile
0.56545%
Introduced Version
0
Fix Available
1.8.0-beta.27

Fix Critical Vulnerabilities Instantly

Secure your app without upgrading.
Fix Without Upgrading