Summary
Grav CMS versions 1.7.x and earlier improperly process XML content within uploaded SVG files, allowing XML External Entity (XXE) expansion.
When an attacker can upload a crafted SVG via the admin panel or File Manager plugin, this behavior may expose sensitive server files or internal network resources.
Affected context
This vulnerability affects Grav CMS deployments that:
- Allow authenticated users (e.g., admins, editors, or other roles) to upload SVG files via the admin panel or File Manager plugin
- Parse SVGs using XML parsers that do not disable external entity resolution
- Treat uploaded SVGs as valid XML without applying strict sanitization or safe XML parser configurations
The issue is most relevant on instances where the web server has access to sensitive files or internal services that should not be exposed to users with upload permissions.
Exploit preconditions
- Attack surface: SVG file upload endpoints reachable via the Grav CMS admin interface and File Manager plugin
- Required access: Ability to authenticate to the CMS and upload SVG files (typically a valid user account with media/upload privileges)
- Trigger point: Server-side processing/parsing of the uploaded SVG file by an XML-capable parser
- Why exploitation is possible: The XML parser used for SVG processing is configured to allow external entities and/or DTD processing, enabling attackers to define entities that reference local files or remote URLs which the server then dereferences
Why this happens
The underlying bug is the use of XML parsers that are not hardened against external entity expansion when handling user-supplied SVG content.
SVG is an XML-based format, and if processed with default or permissive parser settings, it may allow the definition of <!DOCTYPE> and external entities that reference local or remote resources.
This behavior aligns with CWE-611: Improper Restriction of XML External Entity Reference, where an application fails to disable or constrain external entity resolution on untrusted XML input, creating a channel for data exfiltration or server-side requests.
Potential impact
- Disclosure of sensitive local files that the web server process can read (e.g., configuration files, keys, environment files)
- Server-Side Request Forgery (SSRF), where the server makes HTTP requests to internal or external systems controlled by the attacker
- Exposure of internal network structure and reachable services
- Assistance in chaining with other vulnerabilities (e.g., reading credentials that enable further compromise)
- Potential denial of service if the XML parser is abused with resource-intensive entity constructions
General mitigation guidance
Effective mitigation focuses on restricting XML behavior and reducing trust in uploaded SVG content:
- Configure XML parsers used for SVG processing to disable DTDs and external entity resolution by default
- Treat all uploaded SVGs as untrusted; sanitize or normalize them using libraries that strip active XML constructs (e.g., DOCTYPE, entities, scripts)
- Prefer safer media formats where possible (e.g., rasterizing SVGs to images server-side before use)
- Enforce least-privilege for the web server process, including restricted filesystem and network access, to minimize the blast radius of XXE-style issues
- Limit who can upload SVGs and apply role-based controls, especially on production-facing instances
How teams detect issues like this
Detection approaches commonly include:
- Static analysis or configuration checks to identify XML parsing code paths that allow external entities or DTD processing
- Code review guidelines that flag XML parser initialization without explicit hardening flags or safe configuration profiles
- Security tests that upload benign and controlled XXE probe SVGs to verify whether local files or internal endpoints can be accessed
- Centralized logging and monitoring of unexpected outbound HTTP requests from the web server, especially to internal or unusual destinations
- Periodic automated scanning of upload handlers and file-processing components with DAST tools that support XXE testing

