Repository navigation
Description
Bug report
- I confirm this is a bug with Supabase, not with my own application.
- I confirm I have searched the Docs, GitHub Discussions, and Discord.
Describe the bug
Revoking a user's grant for an OAuth client (DELETE /user/oauth/grants?client_id=..., supabase.auth.oauth.revokeGrant()) deletes the client's sessions and refresh tokens, but it leaves in place any authorization codes the client has not exchanged yet. After the revoke, the client can still exchange such a code at POST /oauth/token. It gets a working access token and refresh token for the user who just disconnected it.
The revoked grant also no longer shows up in GET /user/oauth/grants. The user sees the client as disconnected while it holds fresh tokens.
To Reproduce
Tested against supabase/auth v2.198.0 with GOTRUE_OAUTH_SERVER_ENABLED=true and GOTRUE_OAUTH_SERVER_ALLOW_DYNAMIC_REGISTRATION=true.
- Register a client:
POST /oauth/clients/register. - As a signed-in user, start an authorization:
GET /oauth/authorize?response_type=code&client_id=...&redirect_uri=...&code_challenge=...&code_challenge_method=S256&scope=email. - Load and approve it:
GET /oauth/authorizations/{id}, thenPOST /oauth/authorizations/{id}/consentwith{"action": "approve"}. Take thecodefrom the returned redirect URL, but do not exchange it yet. - As the same user, revoke the grant:
DELETE /user/oauth/grants?client_id=.... It returns 204, and the client is gone fromGET /user/oauth/grants. - Exchange the code from step 3:
POST /oauth/tokenwithgrant_type=authorization_code, the code,redirect_uriandcode_verifier.
Expected behavior
Step 5 fails with invalid_grant. Once a user disconnects an app, that app should not be able to get new tokens for them, including from a code issued before the disconnect.
Actual behavior
Step 5 returns 200 with an access token and a refresh token. GET /user with that access token succeeds. The client does not reappear in GET /user/oauth/grants, so the user has no way to see this access or revoke it from the grants list.
Screenshots
Not applicable.
System information
supabase/authv2.198.0 (self-hosted, Docker)@supabase/supabase-jswith@supabase/auth-js2.95.3
Additional context
Impact: The window is bounded by the code lifetime (10 minutes by default), and only the client the code was issued to can use it. It still breaks the guarantee a "disconnect" button gives the user: an app they just disconnected can keep access to their account, and nothing in the UI shows it.
Suggested fix: When revoking a grant, also delete or invalidate the user's pending and approved-but-unexchanged rows in auth.oauth_authorizations for that client, in the same transaction as the session deletion.
Activity