Validate post_logout_redirect_uri to prevent open redirect#71
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
post_logout_redirect_uriwas accepted and redirected to without any validation — an attacker could craft a link like/oauth/logout?post_logout_redirect_uri=https://evil.com/phishingthat logs the user out and sends them to a fake login page.client_idparameter alongsidepost_logout_redirect_uri, looks up the client, and validates the URI is in the client's registeredredirect_uris. Falls back to/oauth/loginif validation fails for any reason.Test plan
Five integration tests covering all validation paths (written red/green TDD — confirmed failures before fix):
/oauth/login/oauth/login/oauth/login/oauth/loginCloses #59.
🤖 Generated with Claude Code