Summary
Grav contains a stored cross-site scripting (XSS) vulnerability where low-privileged users who can create pages may inject malicious SVG content that executes in the browser of visiting administrators.
When a Super Admin opens a crafted page, the payload can exfiltrate sensitive system information from /admin/config/info and, when combined with admin nonces, can be leveraged toward full server compromise (remote code execution).
Affected context
This vulnerability occurs in Grav installations where:
- Users with low privileges are allowed to create or edit pages.
- User-supplied page content can include SVG elements or HTML-like markup.
- Super Admins or other high-privilege users regularly view content created by lower-privileged accounts through the administrative interface or front-end.
The risk materializes when crafted SVG-based payloads are rendered in a browser context that has access to administrative routes and nonces.
Exploit preconditions
- Attack surface: Web-based, through Grav's page creation and rendering functionality.
- Required access: Authenticated low-privileged account capable of creating or editing pages.
- Victim interaction: A Super Admin (or similarly privileged user) must visit or preview the malicious page in a browser.
- Trigger point: Rendering of the malicious SVG content in the admin or front-end view, causing the browser to execute the injected script.
- Why exploitation is possible: User-controlled page content is not sufficiently sanitized or restricted, allowing SVG constructs that can carry executable script behavior to run in the high-privilege user's browser context.
Why this happens
The root cause maps to CWE-79: Improper Neutralization of Input During Web Page Generation (Cross-Site Scripting).
Grav's page creation pipeline allows HTML/SVG elements within user-managed content but does not robustly neutralize or filter SVG-based vectors that can execute script-like behavior.
As a result, untrusted content is rendered directly into pages viewed by high-privilege users, causing the browser to interpret attacker-controlled data as active content within an authenticated admin session.
Potential impact
- Theft of sensitive configuration and system information (e.g., data from
/admin/config/info). - Impersonation of Super Admins via session hijacking or action forgery.
- Abuse of admin nonces to perform privileged actions on behalf of the victim.
- Potential full server compromise (RCE) when XSS is chained with administrative functionality.
- Manipulation of site content, configuration, or user accounts.
General mitigation guidance
Effective mitigation focuses on breaking the trust boundary between user-generated content and the admin's browser:
- Apply strict HTML and SVG sanitization to all user-supplied content, removing any attributes or elements capable of script execution or event handling.
- Consider disallowing SVG or other active content types in user-editable fields unless they pass through a robust sanitizer.
- Enforce a clear separation between content and control: avoid rendering untrusted content inside administrative control pages or consoles.
- Adopt a defense-in-depth browser-side security posture, including a restrictive Content Security Policy (CSP) to reduce the impact of any residual XSS.
- Design administrative actions and nonces so that they cannot be triggered solely via browser-executed scripts originating from user content.
How teams detect issues like this
Potential detection approaches include:
- Static or dynamic analysis of template and content rendering logic to identify paths where user-supplied HTML/SVG is injected without sanitization.
- Code review checklists that explicitly cover SVG handling, HTML sanitization routines, and the boundaries between user content and admin views.
- Integration of automated security scanners or linters that flag unsafe use of raw HTML rendering APIs and absence of sanitization on rich-text inputs.
- Application-level monitoring and logging for unusual admin-side requests that originate from viewing user content (e.g., unexpected calls to
/admin/config/infotriggered by page views).

