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

GHSA-X72C-4JC4-8RH6

SsoController::sanitizeReturnTo() backslash bypass of the in-app-path-only open-redirect guard

Parche disponible
Descargar PNG JSON
CVSS
—
low
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-X72C-4JC4-8RH6 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)
File: `classes/Api/Controllers/SsoController.php`
Lines: `sanitizeReturnTo()`, consumed by `start()` and `callback()`
CWE: CWE-601 — URL Redirection to Untrusted Site ('Open Redirect')
Severity: Medium (confidence: server-side gap confirmed directly; full browser-side exploitability depends on the admin-next SPA's client-side `/oauth-callback` handler, whose JS bundle is not part of this repository, so that final hop could not be independently verified)
CVSS: 4.7 — CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:U/C:N/I:L/A:N

### Root Cause
`sanitizeReturnTo()`'s own docblock states its purpose: accept only an in-app path, reject anything that could be interpreted as pointing off-site — this value round-trips into a redirect, so an open redirect here is a login-phishing vector. It correctly rejects a literal `//` prefix and any value not starting with `/`. It does not account for the WHATWG URL Standard's backslash-normalization behavior: for "special" schemes (http/https), a browser's URL parser treats `\` exactly like `/` while resolving a relative reference, including at the start of a path, where two consecutive slash-or-backslash characters switch the parser into "authority" (host) parsing mode. A value like `/\evil.com`:
- passes `str_starts_with($returnTo, '/')` (true)
- passes `!str_starts_with($returnTo, '//')` (true — second char is `\`, not `/`)
- is accepted verbatim

but a browser resolving `/\evil.com` as a URL reference treats it identically to `//evil.com` — a protocol-relative URL to `evil.com`, exactly the case the function exists to block.

Vulnerable Code
private function sanitizeReturnTo(string $returnTo): string
{
    if ($returnTo === '' || !str_starts_with($returnTo, '/') || str_starts_with($returnTo, '//')) {
        return '';
    }
    return $returnTo;
}

### Attack Scenario
1. Attacker sends a victim: `https://target-site.example/api/v1/auth/sso/<provider>/start?returnTo=/\evil.com`.
2. Victim completes a real OAuth flow with the legitimate provider (not a credential-theft phish at that step — this manipulates the post-login redirect target, not the provider auth itself).
3. `callback()` 302s the browser to `https://target-site.example/admin/oauth-callback?code=<real one-time code>&returnTo=%2F%5Cevil.com` — still same-origin, so nothing looks wrong in the address bar at this hop.
4. Per the class's own documented contract, the admin-next SPA's `/oauth-callback` route reads `returnTo` to send the user back to where they started after the token exchange completes. If it navigates without its own same-origin re-check, `/\evil.com` resolves in the browser as `//evil.com`, sending the freshly-authenticated victim to an attacker-controlled page.

### Impact
- Type: CWE-601 Open Redirect immediately following a real authentication event
- Auth required: No — attacker only crafts the initial link, victim needs no prior relationship with attacker
- Consequence: Post-authentication redirection to an attacker-controlled site, useful for a convincing post-login phishing page (e.g. a fake "session expired, re-authenticate" prompt) — victims are primed to trust the destination since the real login just succeeded.

Recommended Fix
private function sanitizeReturnTo(string $returnTo): string
{
    if ($returnTo === '' || !str_starts_with($returnTo, '/')) {
        return '';
    }
    if (preg_match('#^[/\\\\]{2}#', $returnTo) || str_contains($returnTo, '\\')) {
        return '';
    }
    return $returnTo;
}

### Verification
Dynamically confirmed on grav 2.0.13 / api plugin 1.0.13: called the live `sanitizeReturnTo()` (via reflection, since it's `private`) with `/dashboard` (allowed), `//evil.com` and `https://evil.com` (correctly rejected by the existing checks), and `/\evil.com` / `/\/evil.com` (both accepted verbatim — confirming the gap). After applying the fix, both backslash forms are correctly rejected while `/dashboard` and other in-app paths (e.g. `/foo/bar`) continue to pass unchanged.

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.

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-x72c-4jc4-8rh6

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