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

GHSA-435X-66R2-JWV2

BlueprintPathResolver::resolveUserScope() uses bare access.api.super, letting an api.media.write-scoped key act as if it held api.users.write

Parche disponible
Descargar PNG JSON
CVSS
—
medium
Fuente: —
ExplotaciónSin evidenciaNo figura en CISA KEV
Exploits públicos0Ninguno conocido
Parche1 versión1.0.14
Exposición108 dDesde la divulgación, 3 ago 2026, 9:27 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-435X-66R2-JWV2 divulgada
Monitoreo Detectada Ingresó al índice
Monitoreo Verificada Última verificación contra las fuentes
Resumen
Descripción del advisory
Texto original · GitHub · en inglés

Vulnerability Details

Component: getgrav/grav-plugin-api (bundled with Grav 2.0's admin-next/API stack)
Files: `classes/Api/Services/BlueprintPathResolver.php` (`resolveUserScope()`), `classes/Api/Controllers/BlueprintUploadController.php`, `classes/Api/Controllers/BlueprintFilesController.php`
CWE: CWE-862 — Missing Authorization
Severity: Moderate
CVSS: 5.4 — CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:N/I:L/A:N

### Root Cause
`resolveUserScope()` gates the `users/<name>` scope (used by `POST /blueprint-upload` and `GET /blueprint-files` when a blueprint field's `destination` is `self@:` and `scope=users/<name>`) on: the caller editing their own account, holding `api.users.write`, or being super-admin. The super-admin check was `$isSuper = (bool) $caller->get('access.api.super')` — the account's raw ACL flag, with no reference to the presented API key's actual scope. `BlueprintPathResolver` is a plain service class (not a controller), so it never receives the request or its `api_key_scopes` attribute at all — it was structurally unable to consult the scope-aware helper (`AbstractApiController::isSuperWithinScope()`) already used elsewhere in this codebase for exactly this class of check.

A super-admin who mints an API key scoped to `["api.access", "api.media.write"]` only — intending it for a narrow media-management integration — still has that key pass the `users/<name>` scope gate as if it also held `api.users.write`, purely because the owning account is super.

Vulnerable Code
private function resolveUserScope(string $name, ?UserInterface $caller): ?string
{
    // ...
    $isSelf = strcasecmp($caller->username, $name) === 0;
    $resolver = new PermissionResolver($this->grav['permissions']);
    $isSuper = (bool) $caller->get('access.api.super');   // <-- bare account flag, ignores key scope
    $hasUsersWrite = (bool) $resolver->resolve($caller, 'api.users.write');

    if (!$isSelf && !$isSuper && !$hasUsersWrite) {
        throw new ForbiddenException(/* ... */);
    }
    // ...
}

`BlueprintUploadController::upload()` calls `$this->resolver()->resolve($destination, $scope, $this->getUser($request))` — note it passes the raw `UserInterface`, never the request or its scopes.

### Attack Scenario
1. Super-admin mints a scoped key: `["api.access", "api.media.write"]` only.
2. `POST /blueprint-upload` with `destination=self@:avatar`, `scope=users/<other-username>`, and an image file.
3. `resolveUserScope()` grants it because the account is super, even though the key was never scoped for `api.users.write` and the caller isn't `<other-username>`.

### Impact
- Type: CWE-862 Missing Authorization
- Auth required: A scoped API key (`api.media.write`, not `api.users.write`/`admin.super`) minted on a super-admin account
- Consequence: Writes a file into the shared `user/accounts/` directory "as" another user's scope, and can browse that scope's file listing, using a credential the operator explicitly did not grant users-management authority. Bounded by `assertSafeExtension()`'s independent image-only restriction on this directory — no arbitrary file type reaches disk from this bug alone.

Recommended Fix
// resolve() / resolveScopeRoot() / resolveUserScope() all gain an explicit
// $callerIsSuperWithinScope parameter instead of deriving it internally:
public function resolve(string $input, string $scope, ?UserInterface $caller = null, bool $callerIsSuperWithinScope = false): string { /* ... */ }
public function resolveScopeRoot(string $scope, ?UserInterface $caller = null, bool $callerIsSuperWithinScope = false): ?string { /* ... */ }
private function resolveUserScope(string $name, ?UserInterface $caller, bool $callerIsSuperWithinScope = false): ?string
{
    // ...
    $isSuper = $callerIsSuperWithinScope;   // was: (bool) $caller->get('access.api.super')
    // ...
}
// BlueprintUploadController::upload() / BlueprintFilesController::list()
$targetDir = $this->resolver()->resolve($destination, $scope, $this->getUser($request), $this->isSuperWithinScope($request));

### Verification
Dynamically confirmed on grav 2.0.13 / api plugin 1.0.13, with a control isolating the exact variable: a key scoped to `["api.access", "api.media.write"]` minted on the super-admin account, targeting `scope=users/<other>`, succeeded (HTTP 201) before the fix. An identically-scoped key minted on a genuinely non-super account (with `api.media.write` really granted at the account level) was correctly rejected (HTTP 403) both before and after — isolating that the leak was specifically the bare super check, not a general scope-cap failure. After the fix, the super-admin-account scoped key is correctly rejected with the same 403 message the non-super control always got; an unscoped super-admin session (real super authority, no scope restriction) still succeeds as expected (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.

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
Corregida 1.0.14 — —
Versiones corregidas1.0.14
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-435x-66r2-jwv2

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