GHSA-J9J4-QQ25-7M54
Unauthenticated Host headers cause unbounded cache growth
Texto original en inglés · Ver en español
Ciclo de vida de la vulnerabilidad
| Fecha | Fase | Evento | Detalle |
|---|---|---|---|
| Divulgación | Publicada | GHSA-J9J4-QQ25-7M54 divulgada | |
| Monitoreo | Detectada | Ingresó al índice | |
| Monitoreo | Verificada | Última verificación contra las fuentes |
Summary
An unauthenticated client can make Grav write large amounts of data to disk by varying the HTTP `Host` header. Grav derives its configuration environment from the raw `Host` value and uses it to name its compiled configuration, blueprint and language caches. A second path stores a full copy of the page index per distinct host. There is no trusted-host allowlist and no bound on the number of hosts, so each new `Host` value leaves roughly half a megabyte or more on disk, and an anonymous attacker can fill the disk until sessions, cache writes, uploads and logging fail. This is resource amplification (about a thousand times the size of the request lands on disk) and not denial of service by request volume. This advisory was originally reported for the compiled caches only. It has been re-rated from High to Moderate and now covers the page index path as well.
Affected versions
Grav 2.x from 2.0.0 up to and including 2.2.17. The earlier text of this advisory listed `<= 2.2.16`, which left out 2.2.17. Reachability requires a front end that routes unknown `Host` values to Grav, which the shipped `nginx.conf` (a single `server_name localhost`, used as the default server) and a default Apache virtual host both do. A strict `server_name` or `ServerName` mitigates it. Grav 1.7 derives its environment and its page index namespace from the host in the same way.
Details
Compiled caches. `Setup` sets the environment from `$uri->getHost()` with no allowlist and no existence check. `ConfigServiceProvider` names the compiled caches after it (`master-{environment}` for blueprints, configuration and languages, plus a file-list cache on 2.x), and `CompiledBase` writes a full PHP dump of about 125 to 250 KB for each. A missing environment folder is rejected, but the name still survives into the cache file names. The reporter's reproduction on 2.2.16 (30 requests with distinct hosts against 30 with the same host) grew the cache from 1,148 KiB to 16,752 KiB, about 520 KiB per host, with the same-host control showing no growth. The per-host files are byte-identical copies. A later measurement of 50 new hosts produced 32,156,520 bytes in 350 files, and one 64-byte request left 643,128 bytes.
Page index. `Cache` derives its namespace from the absolute root URL and the configuration key, and `Pages` fetches the index there and stores another copy on a miss. A new host therefore stores a full index copy under a new namespace. Six invented hosts created six namespaces totaling 5,029,146 bytes, each holding an 829,212-byte page index, on a 300-post site with the file cache driver (the default when APCu is not available). The lazy index reduces this on large sites. The compilation timestamp is part of the configuration object, so pinning the base URL alone does not stop the duplicates.
Neither kind of cache file is permanent. The cache purge removes page index entries older than `system.cache.purge_max_age_days` (30 days by default) and compiled files older than twice that (60 days), but only when the purge runs, and a disk can fill long before then.
Impact
Availability. An unauthenticated attacker fills the server disk with redundant cache files, after which sessions, cache writes, uploads and logging fail until the cache is cleared with `bin/grav clearcache`. There is no code execution, data exposure or privilege change. It is rated Moderate because the effect is storage exhaustion that clears with a cache purge.
Patches
Fixed in Grav 2.2.18. Request-derived environments that have no environment folder now share one cache identity based on their stream configuration, while real environment folders and explicitly selected environments stay distinct. This changes the public `setup.environment` and `config.environment` values for hosts without an environment folder. The page index namespace no longer depends on the host, except where frontmatter Twig is enabled and for rendered content that contains absolute URLs. This does not bound every per-host rendered cache entry, so a strict `server_name` is still the complete mitigation.
Workarounds
Make the web server answer only for the site's own names: a strict `server_name` in nginx or `ServerName` with a catch-all virtual host that returns an error in Apache.
Credits
Originally reported by rng70.
Discovered by Anthropic's OSS Scanner (ANT-2026-HR4TBNEV, ANT-2026-CNOAVXII).
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-j9j4-qq25-7m54Las referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.
