Skip to content

Validate post_logout_redirect_uri to prevent open redirect#71

Merged
eswan18 merged 1 commit into
mainfrom
fix/validate-post-logout-redirect-uri
Mar 31, 2026
Merged

Validate post_logout_redirect_uri to prevent open redirect#71
eswan18 merged 1 commit into
mainfrom
fix/validate-post-logout-redirect-uri

Conversation

@eswan18
Copy link
Copy Markdown
Owner

@eswan18 eswan18 commented Mar 31, 2026

Summary

  • Fixes an open redirect vulnerability in the logout handler. Previously, post_logout_redirect_uri was accepted and redirected to without any validation — an attacker could craft a link like /oauth/logout?post_logout_redirect_uri=https://evil.com/phishing that logs the user out and sends them to a fake login page.
  • Now requires a client_id parameter alongside post_logout_redirect_uri, looks up the client, and validates the URI is in the client's registered redirect_uris. Falls back to /oauth/login if validation fails for any reason.
  • Per OIDC RP-Initiated Logout 1.0 Section 2.

Test plan

Five integration tests covering all validation paths (written red/green TDD — confirmed failures before fix):

  • No params → redirects to /oauth/login
  • Valid URI + valid client_id → redirects to the URI
  • Unregistered URI + valid client_id → redirects to /oauth/login
  • Any URI + nonexistent client_id → redirects to /oauth/login
  • Any URI + no client_id → redirects to /oauth/login

Closes #59.

🤖 Generated with Claude Code

Previously, the logout handler accepted any post_logout_redirect_uri and
redirected to it without validation. This was an open redirect
vulnerability — an attacker could craft a logout link that redirects the
user to a phishing site after logout.

Now, post_logout_redirect_uri is only honored when a client_id is also
provided and the URI matches one of that client's registered redirect
URIs. If validation fails (missing client_id, unknown client, or
unregistered URI), the handler falls back to /oauth/login.

Closes #59.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@eswan18 eswan18 merged commit bf03f16 into main Mar 31, 2026
1 check passed
@eswan18 eswan18 deleted the fix/validate-post-logout-redirect-uri branch March 31, 2026 00:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Validate post_logout_redirect_uri against an allowlist

1 participant