GHSA-8MJX-XJFV-9C88
MenubarController::executeAction() never enforces the authorize requirement it advertises
Ciclo de vida de la vulnerabilidad
| Fecha | Fase | Evento | Detalle |
|---|---|---|---|
| Divulgación | Publicada | GHSA-8MJX-XJFV-9C88 divulgada | |
| Monitoreo | Detectada | Ingresó al índice | |
| Monitoreo | Verificada | Última verificación contra las fuentes |
Vulnerability Details
Component: getgrav/grav-plugin-api (bundled with Grav 2.0's admin-next/API stack)
File: `classes/Api/Controllers/MenubarController.php`
Lines: 82-115 (`executeAction()`), 57-77 (`items()`, for comparison)
CWE: CWE-862 — Missing Authorization
Severity: Moderate
CVSS: 5.3 — CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:L/I:L/A:N
### Root Cause
Plugins register menubar items via `onApiMenubarItems` with an optional `authorize` field (a permission string/array). `MenubarController::items()` (the `GET /menubar/items` listing endpoint) correctly filters the returned list using `userPassesAuthorize($user, $item['authorize'], $isSuperAdmin)`. However, `executeAction()` (`POST /menubar/actions/{plugin}/{action}`, the endpoint that actually *runs* the action via `onApiMenubarAction`) only checks the baseline `api.access` permission — it never looks up the `authorize` value the plugin registered for that plugin/action pair. Any authenticated caller with `api.access` can invoke the action directly, bypassing the authorization the item's `authorize` field was designed to enforce, simply by not going through the listing endpoint.
Currently no plugin bundled with core Grav (admin, api, login, form, email, flex-objects, shortcode-core) registers an `onApiMenubarAction` handler with a privileged `authorize` value, so impact on a stock install is latent rather than immediately exploitable — but this is a framework-level contract violation affecting any current or future plugin (first-party or third-party) that relies on the documented `authorize` semantics.
Vulnerable Code
public function executeAction(ServerRequestInterface $request): ResponseInterface
{
$this->requirePermission($request, 'api.access');
$plugin = $this->getRouteParam($request, 'plugin');
$action = $this->getRouteParam($request, 'action');
$body = $this->getRequestBody($request);
// ... fires onApiMenubarAction with no 'authorize' check at all
}### Attack Scenario
1. A plugin registers a menubar item: `['plugin' => 'x', 'action' => 'dangerous-op', 'authorize' => 'admin.super']`.
2. `items()` correctly hides this button from non-super users.
3. A non-super but `api.access`-enabled user (or a purposely-scoped API key) calls `POST /api/v1/menubar/actions/x/dangerous-op` directly.
4. The action executes for a caller who was never authorized for `admin.super`.
### Impact
- Type: CWE-862 Missing Authorization
- Auth required: Yes (baseline `api.access` only — not the specific `authorize` permission the action requires)
- Consequence: Privilege escalation relative to a plugin's declared authorization model; concrete severity scales with whatever the invoked plugin action does.
Recommended Fix
public function executeAction(ServerRequestInterface $request): ResponseInterface
{
$this->requirePermission($request, 'api.access');
$plugin = $this->getRouteParam($request, 'plugin');
$action = $this->getRouteParam($request, 'action');
$user = $this->getUser($request);
$itemsEvent = new Event(['items' => [], 'user' => $user]);
$this->grav->fireEvent('onApiMenubarItems', $itemsEvent);
$isSuperAdmin = $this->isSuperAdmin($user);
$matched = null;
foreach ($itemsEvent['items'] as $item) {
if (($item['plugin'] ?? null) === $plugin && ($item['action'] ?? null) === $action) {
$matched = $item;
break;
}
}
if ($matched !== null && !$this->userPassesAuthorize($user, $matched['authorize'] ?? null, $isSuperAdmin)) {
throw new ForbiddenException("Missing required permission to execute '{$plugin}/{$action}'.");
}
$body = $this->getRequestBody($request);
// ... unchanged from here
}### Verification
Dynamically confirmed on grav 2.0.13 / api plugin 1.0.13 in a local Docker lab: registered a throwaway plugin with a menubar item gated to `authorize => 'admin.super'`; an account holding only baseline `api.access` (no `admin.super`) could not see the item via `GET /menubar/items` but successfully executed it via direct `POST /menubar/actions/.../...` (HTTP 200, action ran). After applying the fix above, the same request correctly returns HTTP 403, while a genuine super-admin caller still succeeds (regression-checked).
A ready-to-apply fix branch is prepared locally against grav-plugin-api's `1.0.13` tag; happy to push it to a private fork once one is available for this advisory.
Incluye detalles técnicos publicados por el investigador. Úselos solo para validar y corregir sus propios sistemas.
Rangos afectados
Estado del parche por paquete
| Paquete / producto | Estado | Corregida en | Desde divulgación | Última versión |
|---|---|---|---|---|
Packagistgetgrav/grav-plugin-api |
Corregida | 1.0.14 | — | — |
1.0.14Arsenal 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-8mjx-xjfv-9c88Las referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.
