[Security] Encoded backslash bypass in post_logout_redirect_uri can cause open redirect

Abierto
#1,811 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
5/5
Tiempo estimado
Más de una semana
Aptitud para principiantes
30/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
azure

Línea de trabajo

Comienza reproduciendo el flujo de dos pasos /.auth/logout y /.auth/logout/complete con los comandos curl proporcionados, conservando la cookie e inspeccionando Location sin seguir las redirecciones. El informe no menciona archivos del repositorio e identifica el comportamiento como gestionado por la plataforma. Se considera completado cuando los destinos no seguros con barras invertidas codificadas se rechazan o se reemplazan por un destino fijo del mismo origen.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Summary

Azure Static Web Apps managed authentication appears to accept an encoded backslash in post_logout_redirect_uri, then reflect the decoded value from /.auth/logout/complete. In browsers, the resulting URL can be normalized as a scheme-relative external redirect.

This appears to be an open redirect in the platform-managed /.auth/* authentication flow.

Affected flow

  1. GET /.auth/logout?post_logout_redirect_uri=/%5Cattacker.example

  2. The request is accepted and establishes the managed-auth logout context.

  3. GET /.auth/logout/complete with the resulting cookie.

  4. The response may be a redirect such as:

    Location: /\\attacker.example

  5. Browser URL normalization can interpret /\\attacker.example as an off-origin scheme-relative URL.

Expected behavior

post_logout_redirect_uri should be accepted only when it is a safe same-origin path, for example /dashboard. Inputs containing backslashes, encoded backslashes, control characters, or any form that can normalize to an authority should be rejected or replaced with a fixed local destination.

Observed behavior

Obvious absolute and scheme-relative external URLs are rejected, but the encoded-backslash form is accepted and reflected by the logout completion endpoint. This suggests validation and browser URL parsing use different normalization rules.

Security impact

An attacker can create a link that appears to target a legitimate Static Web App, but after logout the browser may be redirected to an attacker-controlled origin. This can support phishing and credential-harvesting flows.

Reproduction

Use a test Static Web App domain and a cookie jar:

HOST=https://<static-web-app-domain>

curl -s -D - -o /dev/null -c cookies.txt \
  $HOST/.auth/logout?post_logout_redirect_uri=/%5Cattacker.example

curl -s -D - -o /dev/null -b cookies.txt \
  $HOST/.auth/logout/complete

Please verify the Location header without following redirects. A vulnerable response is one that reflects a value equivalent to /\\attacker.example, which browsers may normalize to an external scheme-relative URL.

Notes

  • This concerns the Azure Static Web Apps managed-auth endpoints, not application route configuration.
  • A staticwebapp.config.json route rule for /.auth/logout does not appear to intercept the reserved managed-auth endpoint before the platform handler processes it.
  • Please treat this as a security report and advise whether Microsoft prefers private disclosure through the MSRC process.

Suggested fix

Normalize and validate the redirect target using browser-compatible URL parsing. Reject backslashes and encoded backslashes before validation, reject any target whose normalized authority differs from the current host, and use a fixed same-origin fallback when validation fails.

Attack flow

                     OPEN REDIRECT via SWA managed-auth
                     affected flow: `/.auth/logout` -> `/.auth/logout/complete`
================================================================================

  ATTACKER                 VICTIM BROWSER                 AZURE STATIC WEB APPS
                                                          (platform managed-auth
                                                           layer, `/.auth/*`)
     |                          |                                   |
     |  phishing link           |                                   |
     |------------------------->|                                   |
     |                          |                                   |
     |         STEP 1: seed the redirect target into the cookie    |
     |                          |                                   |
     |                          |  GET `/.auth/logout`              |
     |                          |    ?post_logout_redirect_uri=/%5Cattacker.example
     |                          |---------------------------------->| 
     |                          |                                   | validate(uri)
     |                          |                                   | `/\` passes
     |                          |   302 Found                       |
     |                          |   Location: `https://identity.5.azurestaticapps.net/`
     |                          |             `.redirect/logout?hostName=...`
     |                          |   Set-Cookie: `StaticWebAppsAuthContextCookie=<enc>`
     |                          |     Secure; HttpOnly; SameSite=None   <-- sent cross-site
     |<-------------------------|                                   |
     |                          |   [target is stored in the managed-auth context]
     |                          |                                   |
     |         STEP 2: trigger the completion handler              |
     |                          |                                   |
     |                          |  GET `/.auth/logout/complete`   |
     |                          |  Cookie: `StaticWebAppsAuthContextCookie=<enc>`
     |                          |---------------------------------->| 
     |                          |                                   | reflect(cookie.uri)
     |                          |   302 Found                       |
     |                          |   Location: `/\attacker.example`  <== TAINTED
     |<-------------------------|                                   |
     |                          |                                   |
     |                          | browser normalizes `/\` -> `//`
     |                          | => scheme-relative URL
     |                          v                                   |
     |                 `https://attacker.example` (off-origin)
     |                          |
     |<-------------------------+   attacker-controlled page
Lenguaje dominante
Sin datos de lenguaje
Estrellas
347
Forks
68
Métricas de merge de PR
Sin PR fusionados en 30 d

Preparar el entorno

Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de Azure/static-web-apps

Todos los issues de Azure/static-web-apps

Issues similares

Más issues de Security

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.