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

Aperta
#1,811 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
30/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
azure

Direzione di ricerca

Inizia riproducendo il flusso in due passaggi /.auth/logout e /.auth/logout/complete con i comandi curl forniti, mantenendo il cookie e ispezionando Location senza seguire i reindirizzamenti. Il report non indica alcun file del repository e identifica il comportamento come gestito dalla piattaforma. Il lavoro è completato quando le destinazioni non sicure contenenti backslash codificati vengono rifiutate o sostituite con una destinazione fissa della stessa origine.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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
Lingua principale
Nessun dato sulla lingua
Stelle
347
Fork
68
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di Azure/static-web-apps

Tutte le issue di Azure/static-web-apps

Issue simili

Altre issue su Security

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.