Skip to content

fix(oauth): bind token exchanges to the original client request (#37704)#37740

Merged
bircni merged 3 commits into
go-gitea:release/v1.26from
lunny:backport_37704
May 17, 2026
Merged

fix(oauth): bind token exchanges to the original client request (#37704)#37740
bircni merged 3 commits into
go-gitea:release/v1.26from
lunny:backport_37704

Conversation

@lunny
Copy link
Copy Markdown
Member

@lunny lunny commented May 17, 2026

Backport #37704

This PR hardens OAuth token exchange validation by binding exchanged credentials to the client and redirect URI that originally obtained them.

What it changes:

  • reject refresh token exchanges when the refresh token belongs to a different OAuth application
  • reject authorization code exchanges when the redirect_uri in the token request differs from the redirect_uri stored with the authorization code
  • add integration coverage for:
    • authorization code exchange with a mismatched redirect URI
    • refresh token reuse across two different dynamically created OAuth applications

Why:

OAuth authorization codes and refresh tokens must remain bound to the client context that originally received them. Without those checks:

  • a valid authorization code can be redeemed against a different registered redirect URI of the same client
  • a refresh token can be replayed by a different OAuth client

@lunny lunny added this to the 1.26.2 milestone May 17, 2026
@lunny lunny added type/bug topic/security Something leaks user information or is otherwise vulnerable. Should be fixed! labels May 17, 2026
@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label May 17, 2026
@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels May 17, 2026
@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels May 17, 2026
@bircni
Copy link
Copy Markdown
Member

bircni commented May 17, 2026

@lunny checks fail

@bircni bircni merged commit 86cc3e8 into go-gitea:release/v1.26 May 17, 2026
26 checks passed
@lunny lunny deleted the backport_37704 branch May 17, 2026 21:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. topic/security Something leaks user information or is otherwise vulnerable. Should be fixed! type/bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants