Repository navigation
Conversation
|
Hi maintainers, thanks for the work on this project. This is my first contribution here, so the CI workflows on this PR are sitting at |
|
Hey @Denx00, thanks for reporting #2877 and for the PR, really appreciate it! We talked this through internally and ended up going a slightly different direction in #2898. It denies OAuth client tokens by default and only allows them on /oauth/userinfo, so GET /user gets blocked entirely instead of sanitized. We also want to get this fix into the next release, so I’m closing this one in favor of that to move faster. It’s mostly a timing call. Thanks again 🙏 |
|
Thanks @cemalkilic, that makes sense, and the deny-by-default approach in #2898 is cleaner. Glad it's fixed. |
Fixes #2877
Summary of Fix
Delegated third-party OAuth 2.1 client tokens (such as MCP connectors) should only have authorization according to their consented scopes and should not possess account-management privileges. I have addressed Issue #2877 by restricting OAuth client access tokens from modifying credentials, factors, or account state, while scope-limiting user profile reads.
Changes Made
OAuth Client Detection (
Session.IsOAuth()):s.IsOAuth()on*models.Sessionto check ifsession.OAuthClientIDis set.isOAuthClientRequest(ctx)ininternal/api/auth.gochecking both JWT claims (client_id) and session data.Route Middleware (
requireNotOAuthClient):403 Forbidden(no_authorization).internal/api/api.go:PUT /user/factors/*(enrollment, challenge, verify, unenroll, recovery codes)/passkeys/*(registration options & verify, delete, patch)/user/identities/*(link, unlink)/user/oauth/grants(grant management)/oauth/authorizations/*(authorization view and consent)/reauthenticate/logoutDefense-in-Depth Handler Checks:
UserUpdate,EnrollFactor,requirePasskeyManagementAAL,DeleteIdentity,LinkIdentity,Reauthenticate,Logout,OAuthServerConsent,UserListOAuthGrants,UserRevokeOAuthGrant).Scope-Limiting on
GET /auth/v1/user:@supabase/supabase-jswith OAuth tokens (getUser()),GET /auth/v1/usernow runs throughsanitizeUserForOAuth():app_metadata,identities,factors) are always stripped.email,phone, anduser_metadataare only included if the respective scopes (email,phone,profile) were explicitly consented.Unit Tests:
internal/api/oauth_client_restriction_test.goandinternal/api/oauthserver/oauth_client_restriction_test.goverifying that OAuth client tokens are blocked from account modification and correctly scope-limited onGET /user.