Summary
Grav Form plugin has a stored cross-site scripting vulnerability in file uploads: SVG sanitization may be skipped when a file uses an unrecognized final extension. An anonymous attacker may upload such a file through a public any-type upload form, and script could run in an administrator's session if the uploaded file is opened.
Affected context
The issue occurs in the Form plugin's Form::uploadFiles() handling of uploads. It is relevant to deployments with public forms that allow uploads of any file type, where uploaded markup can be stored and later opened by an administrator. The reported impact includes potential super-admin creation on Grav 2.x deployments using Admin2.
Exploit preconditions
- Attack surface: A public Grav form that accepts uploads of any file type
- Required access: No authentication is required to submit to the affected public form
- Trigger point: An administrator opens the uploaded file in a context where its markup is interpreted
- Why exploitation is possible: SVG sanitization is based on the file's final extension, so markup may be accepted when an unrecognized extension follows
.svg
Why this happens
The upload handler applies SVG-specific sanitization only when the final file extension is .svg. Files with SVG markup and an unrecognized trailing extension can therefore bypass that check. This is an output-handling flaw that can allow attacker-controlled script to be stored and later executed in a user's browser, mapping to CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting').
Potential impact
- An administrator's browser session could be exposed to attacker-controlled script.
- The script may perform actions with the administrator's privileges.
- On Grav 2.x with Admin2, an attacker could potentially create a super-admin account.
- Other users who open the uploaded file could also be affected, depending on how it is served.
General mitigation guidance
Defensive patterns include treating uploaded files as untrusted regardless of their names or extensions, and validating file content against a strict allowlist of required formats. Consider rejecting unsupported or ambiguous extensions, storing uploads outside executable web content, and serving files with safe content types and download-oriented policies. Public upload features should be limited to the minimum necessary file types, and administrative accounts should use least privilege.
How teams detect issues like this
Review upload handlers for validation or sanitization decisions based solely on file extensions, especially when a filename can contain multiple extensions. Use static analysis and code review to identify paths where uploaded content is stored and later rendered or served without safe content handling. Enforce policies requiring strict upload type allowlists, safe response headers, and tests covering extension edge cases; automated security review tools may help identify related patterns.

