GHSA-MXWR-773Q-23XW
Media uploaders can store script-running SVG and XML files despite the upload sanitizer
Texto original en inglés · Ver en español
Ciclo de vida de la vulnerabilidad
| Fecha | Fase | Evento | Detalle |
|---|---|---|---|
| Divulgación | Publicada | GHSA-MXWR-773Q-23XW divulgada | |
| Monitoreo | Detectada | Ingresó al índice | |
| Monitoreo | Verificada | Última verificación contra las fuentes |
Summary
Grav and its API plugin try to sanitize uploaded SVG files, and block a list of active-content extensions. Three gaps let an account with media upload rights (a publisher, or an account holding only `api.media.write`) store a script-running SVG, XML or XHTML file that is served from the site's own origin. The script runs in the session of anyone who opens the raw file URL, an administrator included. This is an incomplete fix of GHSA-66xf-ggf4-6hmc and GHSA-7vhm-8x52-2r5p, which covered the same family.
Affected versions
Grav 2.x from 2.0.0 up to and including 2.2.17. The inner-extension gap dates from Grav 1.7.0-rc.12, the fail-open sanitizer from 1.7.23, and the extension list has always lacked `xml`. Grav 1.7 has the same code, but the upload requires an account, so no 1.7 release is part of this advisory. The API plugin is affected as well.
Details
Inner extension. Core sanitizes an upload as SVG only when the last extension says SVG. The upload checks accept `defaults` as a media type extension because `media.types.defaults` is the fallback block. `drawing.svg.defaults` is therefore stored unsanitized (while `drawing.svg` is stored empty), and Apache skips the unmapped `.defaults` and types the file by the inner `.svg`, so it is served as `image/svg+xml` with its script. The pre-check for XSS is dodged with a namespaced root such as `<s:svg>`. The API plugin's `isSvgUpload()` checks the last extension plus a `<svg` sniff that misses namespaced roots, and it accepts any extension that is not on the dangerous list, so `y.svg.foo` through admin2's normal media upload is stored raw. The reproducer uses a Flex front-end form, but this API route is easier.
Fail-open sanitizer. `Security::sanitizeSVG()` quarantines a file only when the sanitizer returns `false`, but the DOM sanitizer returns a string or throws (a `ValueError` after its doctype pattern consumes the file) or exceeds the time limit. The API and core's upload code move the file into the public folder first and sanitize afterwards, so the raw file stays. A 127-byte payload makes the upload answer 500 and leaves the raw file served with its `onload` attribute.
Extension list. `security.uploads_dangerous_extensions` omits `xml` and `xhtm` (the 66xf fix added `xhtml`, `xht` and `svgz`). The API accepts `report.xml` and `report.xhtm` with 201 and they are served with XML types.
Impact
Script runs on the site origin when an administrator opens the file URL. That needs the administrator to navigate to the raw file, which the normal admin flow does not do, and it depends on how the web server types the file. The original report rated these High. They are rated Medium, as GHSA-66xf and GHSA-7vhm were, for the same reason.
Patches
Fixed in Grav 2.2.18. The `defaults` extension is refused as an upload type. The SVG decision uses a shared helper that checks every extension part, so a name such as `drawing.svg.foo` is sanitized. A sanitizer that throws or fails now quarantines the file, and the stored file is emptied before sanitizing so a fatal error leaves it empty. `xml`, `xhtm`, `xsl`, `xslt`, `atom`, `rss`, `rdf` and `mml` are added to `security.uploads_dangerous_extensions`, so `.xml`, `.xhtm` and the other XML formats a browser renders are blocked by default. That is a behavior change for sites that attach XML files, which can take `xml` out of `uploads_dangerous_extensions` in their security configuration. Update the Form plugin to 9.1.38 as well, which refuses and removes an SVG upload the sanitizer cannot clean instead of keeping it as it was sent, and the API plugin to 1.1.6, which uses the same SVG check with a namespace-aware sniff and sanitizes the file in temporary storage before moving it into the media folder.
Workarounds
Send `Content-Security-Policy: sandbox` and `X-Content-Type-Options: nosniff` on static files served from `user/` and `images/`. That neutralizes script in SVG, XML and XHTML regardless of the file name.
Credits
Discovered by Anthropic's OSS Scanner (ANT-2026-QFPA37QT, ANT-2026-5H3YQ3WM, ANT-2026-SHNZNOI3).
Rangos afectados
Estado del parche por paquete
| Paquete / producto | Estado | Corregida en | Desde divulgación | Última versión |
|---|---|---|---|---|
Packagistgetgrav/grav |
Corregida | 2.2.18 | — | — |
2.2.18Arsenal público
Sin exploits, módulos ni PoC públicos conocidos a la fecha de verificación.
https://github.com/getgrav/grav/security/advisories/GHSA-mxwr-773q-23xwLas referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.
