CVE-2025-66297: Grav vulnerable to Privilege Escalation and Authenticated Remote Code Execution via Twig Injection

Published Dec 1, 2025
·
Updated

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() %} 4. 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() %} 3. 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.

Other sources

Grav is a file-based Web platform. Prior to 1.8.0-beta.27, 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. This vulnerability is fixed in 1.8.0-beta.27.

MITRE

Affected Software

29 affected componentsFixes available
Grav Grav CMS<1.8.0-beta.27
composer/getgrav/grav<1.8.0-beta.27
1.8.0-beta.27
getgrav grav<1.8.0
getgrav grav=1.8.0-beta1
getgrav grav=1.8.0-beta10
getgrav grav=1.8.0-beta11
getgrav grav=1.8.0-beta12
getgrav grav=1.8.0-beta13
getgrav grav=1.8.0-beta14
getgrav grav=1.8.0-beta15
getgrav grav=1.8.0-beta16
getgrav grav=1.8.0-beta17
getgrav grav=1.8.0-beta18
getgrav grav=1.8.0-beta19
getgrav grav=1.8.0-beta2
getgrav grav=1.8.0-beta20
getgrav grav=1.8.0-beta21
getgrav grav=1.8.0-beta22
getgrav grav=1.8.0-beta23
getgrav grav=1.8.0-beta24
getgrav grav=1.8.0-beta25
getgrav grav=1.8.0-beta26
getgrav grav=1.8.0-beta3
getgrav grav=1.8.0-beta4
getgrav grav=1.8.0-beta5
getgrav grav=1.8.0-beta6
getgrav grav=1.8.0-beta7
getgrav grav=1.8.0-beta8
getgrav grav=1.8.0-beta9

Event History

Dec 1, 2025
CVE Published
via MITRE·09:05 PM
Data Sourced
via MITRE·09:05 PM
DescriptionWeakness
Data Sourced
via NVD·09:15 PM
RemedyDescriptionSeverityWeaknessAffected Software
Dec 2, 2025
Advisory Published
via GitHub·01:24 AM
Data Sourced
via GitHub·01:24 AM
DescriptionWeaknessAffected Software
Free Weekly Intel

Don't miss critical vulnerabilities

Join thousands of security professionals who receive our weekly digest of trending CVEs, zero-days, and exploited vulnerabilities.

No spam. Unsubscribe anytime.

Frequently Asked Questions

1

What is the severity of CVE-2025-66297?

CVE-2025-66297 has a high severity rating due to its potential for privilege escalation.

2

How can I mitigate CVE-2025-66297?

To mitigate CVE-2025-66297, update Grav CMS to version 1.8.0-beta.27 or later.

3

Who is affected by CVE-2025-66297?

Users with admin panel access to Grav CMS versions prior to 1.8.0-beta.27 are affected by CVE-2025-66297.

4

What kind of attack does CVE-2025-66297 facilitate?

CVE-2025-66297 facilitates privilege escalation through the injection of malicious Twig expressions in page frontmatter.

5

Is there a patch available for CVE-2025-66297?

Yes, a patch is available in Grav CMS version 1.8.0-beta.27 and later.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203