Skip to content

OAuth 2.1 server: authorization codes issued before a grant is revoked can still be exchanged for tokens #2942

Open

Description

@janpio

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.

  1. Register a client: POST /oauth/clients/register.
  2. 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.
  3. Load and approve it: GET /oauth/authorizations/{id}, then POST /oauth/authorizations/{id}/consent with {"action": "approve"}. Take the code from the returned redirect URL, but do not exchange it yet.
  4. As the same user, revoke the grant: DELETE /user/oauth/grants?client_id=.... It returns 204, and the client is gone from GET /user/oauth/grants.
  5. Exchange the code from step 3: POST /oauth/token with grant_type=authorization_code, the code, redirect_uri and code_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/auth v2.198.0 (self-hosted, Docker)
  • @supabase/supabase-js with @supabase/auth-js 2.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

  1. added
    bug
    on Nov 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions