llamaCVEVulnerability Intelligence
/
Advisory · GitHub · Packagist · getgrav/grav-plugin-api

GHSA-66XF-GGF4-6HMC

grav-plugin-api media upload: the SVG sanitizer is keyed on the literal extension "svg", so .svgz and .xhtml pass the denylist unsanitized and are stored as script-executing files (sibling gap of GHSA-7vhm-8x52-2r5p / CVE-2026-61607)

Sin parche publicado
Descargar PNG JSON
CVSS 3.1
4.6
Media
CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:U/C:L/I:L/A:N Fuente: GitHub
ExplotaciónSin evidenciaNo figura en CISA KEV
Exploits públicos0Ninguno conocido
ParcheSin parcheEl fabricante no ha publicado corrección
Exposición108 dDesde la divulgación, 3 ago 2026, 9:25 a. m.
Detección107 dDesde la divulgación hasta su ingreso al índice
Timeline

Ciclo de vida de la vulnerabilidad

Hoy
Divulgación
Publicada
Explotación
Remediación
Monitoreo
Detectada +1
3 ago 26
18 nov 26
20 nov 26
3 ago 26
30 ago 26
26 sept 26
24 oct 26
20 nov 26
FechaFaseEventoDetalle
Divulgación Publicada GHSA-66XF-GGF4-6HMC divulgada · CVSS 4.6 (GitHub)
Monitoreo Detectada Ingresó al índice
Monitoreo Verificada Última verificación contra las fuentes
Resumen
Descripción del advisory
Texto original · GitHub · en inglés

The plugin-api upload gate is a denylist plus an SVG sanitizer that only fires when the extension string is exactly `svg`, so `.svgz` (gzipped SVG) and `.xhtml` clear both checks and are written to disk verbatim even though browsers render them inline and run script in them.

The sanitizer gate, `classes/Api/Controllers/HandlesMediaUploads.php:157-158`:

if (strtolower(pathinfo($filename, PATHINFO_EXTENSION)) === 'svg') {
    Security::sanitizeSVG($targetPath);
}

The comment immediately above it states the threat model precisely: an SVG "can carry executable `<script>`/event-handler payloads that run when the file is later served inline as image/svg+xml". A `.svgz` file is that same format, gzip-wrapped. Apache's stock mime config carries `AddType image/svg+xml svg svgz` together with `AddEncoding x-gzip svgz`, so the same bytes reach the same renderer, and the string comparison above sends it straight past `sanitizeSVG()`.

The only other gate is the denylist at `HandlesMediaUploads.php:167-193`, which reads `security.uploads_dangerous_extensions`. That list (grav 2.0.14, `system/config/security.yaml:45-67`) is php, php2, php3, php4, php5, phar, phtml, html, htm, shtml, shtm, js, exe, md, yaml, yml, json, twig, ini. It contains neither `svgz` nor `xhtml`. The presence of `html`, `htm`, `shtml` and `shtm` on that list is what makes `xhtml` an omission rather than a judgement call: those four are blocked precisely because the browser renders them and executes their script, and `application/xhtml+xml` does the same thing. The post-GHSA-66v2-vxxf-xc3v hardening in that function now walks every dot-separated component rather than just the last, which closes double-extension tricks but does not add any entry to the list.

The field `accept` allowlist is not a second line of defence here, because it is supplied by the caller. `parseUploadFieldSettings()` at `HandlesMediaUploads.php:79-82` builds it from the request's own parsed body and falls back to `UploadFieldSettings::none()`, which the docblock describes as an inert object. The same docblock calls the denylist the "immovable security floor", which is accurate: it is the only floor, and it has these two holes.

The extension itself is attacker-controlled, `HandlesMediaUploads.php:124`:

$originalName = $file->getClientFilename() ?? 'upload';

Reachable from `POST /api/v1/pages/{route}/media` (`ApiRouter.php:568` -> `MediaController::uploadPageMedia`, `MediaController.php:107,119`), `POST /api/v1/media` (`MediaController.php:459,463`), and `BlueprintUploadController.php:114`. All of these gate on `api.media.write` (`MediaController.php:90`), the distinct low-privilege "Upload/Delete Media" scope, well below users, config or super.

The stored file is then reachable as a static file. Grav's shipped `.htaccess` sends any request whose target exists on disk straight to the webserver (`RewriteCond %{REQUEST_FILENAME} !-f`, line 51), and the per-type block for `user/` at line 77 lists txt, md, json, yaml, yml, php, php2-5, phar, phtml, pl, py, cgi, twig, sh, bat. Note that the sibling rule for `system/` and `vendor/` one line above it (line 75) does include html, htm, shtml and xml, while the `user/` rule does not. So `/user/media/payload.xhtml` and `/user/pages/<page>/payload.svgz` are served directly.

The correctly-implemented sibling

The same plugin already has the right pattern where it matters most. `UsersController::uploadAvatar()` (`UsersController.php:1195-1208`) ignores the client-supplied name entirely and derives the type from the bytes:

$info = @getimagesizefromstring($contents);
...
$mime = (string) $info['mime'];

with a comment citing GHSA-xc64-vh46-vph6. `PreferencesController::uploadLogo()` does the same. The media pipeline is the one that still trusts `getClientFilename()` and a string comparison.

Impact

A holder of `api.media.write` stores a file that executes script in the site origin when an admin or a visitor opens or embeds it. That is the same actor, same sink and same outcome as CVE-2026-61607, which is why I have kept the CVSS vector identical to that advisory rather than arguing for more.

Secondary, and explicitly not the basis for the rating: the denylist stops at `php5` and omits `php7`, `php8`, `pht`, `phps` and `phtm`. On a server whose PHP handler is mapped over those suffixes, which is a common `AddHandler` line, the same `api.media.write` caller reaches code execution instead of XSS, a suffix-coverage gap alongside CVE-2026-61606. This one depends on server configuration, so treat it as a reason to extend the list rather than as a separate finding.

Scope of what I verified

I read the code at grav-plugin-api 1.0.14 (commit 042aff8) and grav 2.0.14, and confirmed at those released tags: the `=== 'svg'` gate, the full contents of the denylist, that the extension originates from `getClientFilename()`, that `parseUploadFieldSettings` reads the request body, and the two `.htaccess` rules. I did not run an upload against a live instance and did not observe a browser executing either payload, so the inline-rendering step rests on stock Apache mime behaviour for `xhtml` and `svgz` rather than on something I measured. Grav does not control that mapping, but a deployment behind nginx without those types configured would serve the files as a download instead, so the practical impact varies with the webserver.

Suggested fix

Sanitize by content rather than by extension string: route any XML-family image through `Security::sanitizeSVG()`, transparently decompressing and recompressing for `svgz`, and prefer a positive allowlist plus a content or mime check the way `uploadAvatar` and core's `MediaUploadTrait` already do. As an immediate stopgap that costs nothing, add `svgz`, `xhtml`, `xht`, `php7`, `php8`, `pht`, `phps` and `phtm` to `uploads_dangerous_extensions` and bring the `user/` rule in `.htaccess` into line with the `system|vendor` rule above it.

I used AI assistance while reading the code and preparing this report.

Vector CVSS 3.1

Desglose de métricas

Opción resaltada = valor del vector · izquierda = peor caso · GitHub
Vector de ataqueAV:N
RedAdyacenteLocalFísica
ComplejidadAC:L
BajaAlta
PrivilegiosPR:L
NingunoBajosAltos
InteracciónUI:R
NingunaRequerida
AlcanceS:U
CambiadoSin cambio
ConfidencialidadC:L
AltoBajoNinguno
IntegridadI:L
AltoBajoNinguno
DisponibilidadA:N
AltoBajoNinguno
Versiones

Rangos afectados

Afectada Corregida
getgrav/grav-plugin-api≤ 1.0.14
1.0.14
Remediación

Estado del parche por paquete

Paquete / productoEstadoCorregida enDesde divulgaciónÚltima versión
Packagistgetgrav/grav-plugin-api
Sin parche — — —
Explotación

Arsenal público

Sin exploits, módulos ni PoC públicos conocidos a la fecha de verificación.

Referencias
Advisoryhttps://github.com/getgrav/grav/security/advisories/GHSA-66xf-ggf4-6hmc

Las referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.