CVE-2026-56701: Grav is Vulnerable to XXE via SVG Upload
Dear Grav Security Team, A security vulnerability was discovered in Grav CMS that allows authenticated attackers to read arbitrary files from the server through XML External Entity (XXE) injection. Vulnerability Summary Field Details ---------------- Vulnerability Type XML External Entity (XXE) Injection Severity High (CVSS 7.5) Affected Versions Grav CMS and declarations before parsing, and calls…
Published May 5, 2026 · Updated Sep 23, 2026
Affected packages
getgrav/grav
- Ecosystem
- Composer (PHP)
- Affected
- < 2.0.0-beta.2
- Fixed in
- 2.0.0-beta.2
- Check
composer show getgrav/grav
Advisory details
From the GitHub Advisory Database (CC BY 4.0).
Dear Grav Security Team,
A security vulnerability was discovered in Grav CMS that allows authenticated attackers to read arbitrary files from the server through XML External Entity (XXE) injection.
Vulnerability Summary
| Field | Details | | Vulnerability Type | XML External Entity (XXE) Injection | | Severity | High (CVSS 7.5) | | Affected Versions | Grav CMS <= 1.7.x | | Affected Component | SVG file upload/processing | | CWE | CWE-611: Improper Restriction of XML External Entity Reference | | Authentication Required | Yes (Admin panel access) |
Technical Details
Root Cause The application uses simplexml_load_string() to process uploaded SVG files without disabling external entity loading. This allows attackers to inject XXE payloads that are processed by the XML parser.
Vulnerable Code Pattern
// Current (Vulnerable):
$svg = simplexml_load_string($content);
// No LIBXML_NOENT flag or entity loader protectionAttack Vector
- Attacker authenticates to Grav admin panel
- Uploads malicious SVG file via Pages → Media or File Manager plugin
- Server parses SVG and processes XXE entities
- Arbitrary file contents are exfiltrated
Impact
An authenticated attacker can:
- Read sensitive files:
/etc/passwd- System user informationuser/accounts/*.yaml- Admin credentials and 2FA secretsuser/config/system.yaml- System configuration.envfiles - Environment secrets and API keys
- Perform SSRF - Access internal services via external entity URLs
- Potential DoS - Billion laughs attack via recursive entity expansion
Proof of Concept
Malicious SVG Payload
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE svg [
<!ENTITY xxe SYSTEM "file:///etc/passwd">
]>
<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100">
<text x="10" y="50">&xxe;</text>
</svg>Steps to Reproduce
- Login to Grav CMS admin panel
- Navigate to Pages → select any page → Media tab
- Upload the malicious SVG file
- Observe file contents in response/error or stored output
Recommended Fix
Option 1: Add XXE Protection Flags
libxml_use_internal_errors(true);
$svg = simplexml_load_string($content, 'SimpleXMLElement', LIBXML_NOENT | LIBXML_DTDLOAD);Option 2: Use SVG Sanitizer Library (Recommended)
use enshrined\svgSanitize\Sanitizer;
$sanitizer = new Sanitizer();
$sanitizer->removeRemoteReferences(true);
$cleanSVG = $sanitizer->sanitize($content);The enshrined/svg-sanitize library properly strips XXE payloads and other malicious SVG content.
Request
- Please acknowledge receipt of this report within 5 business days
- Please provide an estimated timeline for a security patch
- I am happy to assist with testing the fix
- I request a CVE be assigned for this vulnerability
- If you have a security advisory process, please include me in the credits
Turki Almatrafi.
---
Maintainer note — fix applied (2026-04-24)
Fixed across two repos:
- Grav core on the `2.0` branch (commit `5a12f9be8`, ships in 2.0.0-beta.2) —
VectorImageMedium::__construct(the code path that reads width/height from an uploaded SVG) now strips<!DOCTYPE>and<!ENTITY>declarations before parsing, and callssimplexml_load_stringwithLIBXML_NONET | LIBXML_NOERROR | LIBXML_NOWARNING. On PHP < 8 it also callslibxml_disable_entity_loader(true)for the duration of the parse.
- rhukster/dom-sanitizer (commit `02d08ec`) — the library Grav ships as its SVG sanitizer.
loadDocumentnow applies the same DOCTYPE/ENTITY strip and passesLIBXML_NONETtoloadXML/loadHTML.
With both layers in place, the PoC:
<!DOCTYPE svg [
<!ENTITY xxe SYSTEM "file:///etc/passwd">
]>
<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100">
<text x="10" y="50">&xxe;</text>
</svg>no longer expands &xxe;, and the parser cannot make outbound filesystem or network requests for external entities/DTDs. Billion-laughs-style entity expansion is also neutralized because the declarations are stripped before libxml ever sees them.
Files:
- `system/src/Grav/Common/Page/Medium/VectorImageMedium.php`.
- `tests/unit/Grav/Common/Security/SvgXxeSecurityTest.php` — XXE neutralization + billion-laughs + plain-SVG regression.
- dom-sanitizer: `src/DOMSanitizer.php` + two new XXE tests in its own suite.
References
- https://github.com/getgrav/grav/security/advisories/GHSA-3446-6mgw-f79p
- https://github.com/getgrav/grav/commit/5a12f9be8314682c8713e569e330f11805d0a663
- https://nvd.nist.gov/vuln/detail/CVE-2026-56701
- https://www.vulncheck.com/advisories/grav-xml-external-entity-injection-via-svg-upload
- https://github.com/advisories/GHSA-3446-6mgw-f79p
How this page is made: the data panel comes from the GitHub Advisory Database, CISA’s KEV catalog, the NVD and FIRST EPSS, and updates twice a day. No analysis has been written for this entry yet. Methodology
More Composer (PHP) vulnerabilities
All Composer (PHP) entriesCVE-2026-61449
Grav: Decompression-bomb size cap bypassed by forged ZIP size in ZipArchiver/Installer
medium6.5Sep 17, 2026CVE-2026-65608
Grav: FlexDirectory::dynamicDataField() executes arbitrary callables from blueprint data with no validation
high8.8Sep 17, 2026CVE-2026-69088
Grav: Incomplete callable validation in blueprint dynamic fields allows arbitrary static method invocation and file disclosure
high8.1Sep 17, 2026CVE-2026-69089
Grav: Path Traversal in ImageMedium::watermark() — arbitrary file disclosure via publicly-cached images
high8.7Sep 17, 2026CVE-2026-72695
Grav: Path Traversal in MediaUploadTrait::deleteFile() Allows Arbitrary File Deletion
high8.1Sep 17, 2026CVE-2026-72697
Grav: media_directory() Twig function allows filesystem path traversal and file content disclosure from sandboxed page content
high6.5Sep 17, 2026
