GHSA-5H3F-PVR7-CR27
Incomplete URL normalization in the Sane sanitizer for SVG files
CVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:P/VC:N/VI:N/VA:N/SC:L/SI:N/SA:L
Fuente: GitHub
Ciclo de vida de la vulnerabilidad
| Fecha | Fase | Evento | Detalle |
|---|---|---|---|
| Divulgación | Publicada | GHSA-5H3F-PVR7-CR27 divulgada · CVSS 5.1 (GitHub) | |
| Monitoreo | Detectada | Ingresó al índice | |
| Monitoreo | Verificada | Última verificación contra las fuentes |
TL;DR
This vulnerability affects all Kirby sites that accept SVG uploads from users who may not be fully trusted, as well as sites that pass untrusted SVG through `Sane::sanitizeFile()`, `$file->sanitizeContents()` or a sanitizing `file.create:before` hook. The attack requires an authenticated Panel user with permission to upload files.
Your Kirby sites are *not* affected if every user who can upload files is fully trusted, or if SVG uploads are not accepted by any of your file blueprints. This is not a cross-site scripting issue: the `javascript:`, `vbscript:`, `data:` and related schemes remain correctly blocked.
This vulnerability is of medium severity for affected sites.
----
Affected components
`Dom::isAllowedUrl()` is the URL gate for every handler in the `Kirby\Sane` package. It is reached through `Sane\Svg::validate()`, which Kirby's default upload protection performs on every uploaded SVG, as well as `Sane\Svg::sanitize()`, `Sane::sanitizeFile()`, `$file->sanitizeContents()` and any site or plugin code that cleans uploaded SVG or HTML. It is applied to link and source attributes and to URLs extracted from `<style>` elements.
The `Sane\Svg` handler is the one that matters here: it restricts SVG documents to referencing no external domain at all. The `Sane\Html` and `Sane\Xml` handlers inherit a permissive domain default and are not meaningfully affected.
Alongside the URL checks, the same shortcoming affected the guard in `Sane\Svg::sanitizeAttr()` that blocks e.g. nested `<use>` constructs.
Impact
In affected releases, several of the sanitizer's restrictions inspected the raw attribute value rather than the value a browser would resolve. A URL could therefore be accepted even though the rule being enforced would have rejected what it actually points to.
An authenticated Panel user who can upload an SVG could use this to store a file that Kirby accepted as clean but that still references an attacker-controlled origin. When such a file is rendered, the reference is fetched, disclosing the viewer's IP address, User-Agent and request timing to a third party; a link inside the document can likewise point off-site, in a document whose domain policy is supposed to be empty. The same shortcoming allowed the nested `<use>` guard to be skipped, so an uploaded SVG could exhaust the resources of the browser rendering it.
Patches
The problem has been patched in Kirby 5.6.0 https://github.com/getkirby/kirby/releases/tag/5.6.0 and Kirby 4.9.6 https://github.com/getkirby/kirby/releases/tag/4.9.6.
In these releases, a new `Url::normalize()` method brings a URL into the same form a browser derives from it before resolving it. `Dom::isAllowedUrl()` now runs all of its checks against this normalized form, and `Sane\Svg::sanitizeAttr()` normalizes the attribute value the same way before it inspects it, so the nested `<use>` guard applies again.
Note that SVG files that were accepted before the patch may still contain such references.
Workarounds
Until you can update:
- Do not accept SVG uploads from users you do not fully trust.
- Embed uploaded SVG files through an `<img>` element rather than inlining them. This covers the external reference vectors, but not the nested `<use>` one.
Credits
Thanks to @iRevivalx for responsibly reporting the identified issue.
Desglose de métricas
Rangos afectados
Estado del parche por paquete
| Paquete / producto | Estado | Corregida en | Desde divulgación | Última versión |
|---|---|---|---|---|
Packagistgetkirby/cms |
Sin parche | — | — | — |
Arsenal público
Sin exploits, módulos ni PoC públicos conocidos a la fecha de verificación.
https://github.com/getkirby/kirby/security/advisories/GHSA-5h3f-pvr7-cr27Las referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.
