Grav Form Plugin Anonymous Page Content Overwrite Vulnerability
Grav Form plugin versions before 9.1.0 allow unauthenticated users to overwrite page content by uploading a malicious markdown file, leading to potential privilege escalation by crafting a new super-admin user.
The Grav CMS Form plugin, specifically in versions prior to 9.1.0, contains a vulnerability allowing unauthenticated users to overwrite existing page content. This flaw resides in the file upload handling mechanism within user/plugins/form/classes/Form.php, where the filename of an uploaded file can be controlled via a POST request. The Utils::checkFilename() function insufficiently filters filenames, failing to block .md extensions. By exploiting this, an attacker can upload a malicious .md file, crafted to overwrite the content of an existing page. This enables attackers to inject arbitrary content, including YAML frontmatter, leading to privilege escalation by creating new administrator accounts. This vulnerability was tested on Form version 9.0.3, released on April 28th.
Attack Chain
- An unauthenticated attacker identifies a Grav page using the Form plugin with a file upload field that accepts all file types (
accept: ['*']). - The attacker crafts a malicious
.mdfile containing YAML frontmatter designed to create a new administrator account (e.g.,viaup.yamlas described in the PoC). - The attacker uploads the malicious
.mdfile, setting thefilenameparameter in the POST request to match the target page’s content file name (e.g.,form.md). - The
Form::uploadFiles()function processes the upload, using the attacker-controlled filename to store the file in flash storage. - Upon form submission,
Form::copyFiles()moves the uploaded file to its final destination, overwriting the original.mdfile of the target page. - The attacker accesses the target page via a
GETrequest, causing Grav to parse the newly overwritten.mdfile and its injected YAML frontmatter. - The injected YAML frontmatter creates a new super-admin user.
- The attacker uses the credentials of the newly created super-admin user to log in and gain administrative control of the Grav CMS instance.
Impact
Successful exploitation of this vulnerability allows unauthenticated attackers to overwrite existing page content, inject malicious code, and ultimately escalate their privileges to super-admin. This grants them complete control over the Grav CMS instance, potentially leading to data theft, website defacement, or further malicious activities. This vulnerability impacts any Grav page allowing file uploads with insufficiently restricted file types and can result in complete compromise of the Grav CMS.
Recommendation
- Apply the remediation patch described in the advisory by upgrading to Grav Form plugin version 9.1.0 or later to address CVE-2026-42845.
- Implement the provided code snippet within
user/plugins/form/classes/Form.phpto block uploads of sensitive page content file types (.md,.yaml,.yml,.json,.twig) to prevent page content overwrites. - Add
md, yaml, yml, json, twig, inito thesecurity.uploads_dangerous_extensionslist in Grav’s configuration to prevent these file types from being processed. - Deploy the Sigma rule “Detect Grav Form Plugin Page Content Overwrite Attempt” to identify potential exploitation attempts by monitoring for uploads of markdown or YAML files to the pages directory.
- Monitor web server logs for POST requests to form submission endpoints that contain the
filenameparameter with values matching page content filenames (e.g.,form.md,default.md).
Detection coverage 2
Detect Grav Form Plugin Page Content Overwrite Attempt
highDetects attempts to upload markdown or YAML files via the Grav Form plugin, potentially overwriting existing page content.
Detect Grav Admin User Creation via Form Submission
criticalDetects attempts to create new admin users by abusing the Grav Form plugin vulnerability.
Detection queries are kept inside the platform. Get full rules →