Skip to content

fix(oauth2): 修复 redirect_uri 校验绕过#355

Merged
zhou-hao merged 2 commits into
hs-web:5.0.xfrom
zhou-ai-bot:codex/fix-oauth2-redirect-uri-validation
May 19, 2026
Merged

fix(oauth2): 修复 redirect_uri 校验绕过#355
zhou-hao merged 2 commits into
hs-web:5.0.xfrom
zhou-ai-bot:codex/fix-oauth2-redirect-uri-validation

Conversation

@zhou-ai-bot
Copy link
Copy Markdown
Contributor

@zhou-ai-bot zhou-ai-bot commented May 19, 2026

Summary

  • replace prefix-based redirect URI validation with URI component checks
  • add hsweb.oauth2.redirect-uri-validation-mode to keep COMPATIBLE behavior by default and allow opt-in EXACT matching
  • reject redirect URIs with fragment and bind authorization codes to the authorized redirect_uri during token exchange
  • add regression tests for compatible matching, exact matching, and authorization code redirect URI binding

Testing

  • mvn -pl hsweb-authorization/hsweb-authorization-oauth2 -am -Dtest=OAuth2ClientTest,DefaultAuthorizationCodeGranterRedirectUriTest -Dsurefire.failIfNoSpecifiedTests=false test

Notes

  • redirect URIs with fragment are rejected because authorization code responses append parameters in the query string; if the registered callback contains #fragment, the returned code and state would end up after # and would not be sent to the server as standard query parameters
  • mvn -pl hsweb-authorization/hsweb-authorization-oauth2 -am test is currently blocked by an unrelated existing failure in hsweb-datasource-api (DefaultSwitcherTest)

Closes #354

@zhou-hao zhou-hao merged commit c288267 into hs-web:5.0.x May 19, 2026
1 check passed
@zhou-ai-bot zhou-ai-bot deleted the codex/fix-oauth2-redirect-uri-validation branch May 19, 2026 06:44
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.

[Security] OAuth2 redirect_uri 校验可通过 URL userinfo 绕过

2 participants