auth: Multi-Session Authentication Bug: Local Logout Invalidates All Sessions

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

When multiple sessions are enabled (SESSIONS_SINGLE_PER_USER = false), logging out from one device incorrectly invalidates sessions on all other devices, even when using scope: 'local'. This breaks the expected behavior of independent multi-device sessions where local logout should only affect the current session.

To Reproduce

Steps to reproduce the behavior:

  1. Configure GoTrue with SESSIONS_SINGLE_PER_USER = false to enable multiple sessions
  2. Login on Device A using supabase.auth.signInWithPassword()
  3. Login on Device B using the same credentials with supabase.auth.signInWithPassword()
  4. Verify both devices have active sessions by calling supabase.auth.getSession() on both
  5. On Device A, call supabase.auth.signOut({ scope: 'local' })
  6. On Device B, call supabase.auth.getSession()
  7. See error: Device B session is invalidated and returns “session not found”

Expected behavior

  • signOut({ scope: 'local' }) should only revoke the current session on Device A
  • getSession() on Device B should continue working with valid refresh tokens
  • Multiple active sessions should remain completely independent
  • Each device should maintain its own isolated session and refresh token family

Screenshots

N/A - This is a backend authentication logic issue

System information

  • OS: macOS, Linux (server-side issue affects all platforms)
  • Browser: All browsers (affects backend GoTrue authentication)
  • Version of supabase-js: Latest (issue is in GoTrue backend, not client library)
  • Version of Node.js: N/A (GoTrue is written in Go)
  • GoTrue Version: Current main branch

Additional context

Root Cause Analysis:

  • Multiple devices receive identical session tokens instead of unique ones
  • All devices share the same refresh token family, causing cross-device token invalidation
  • Local logout operations affect shared session resources instead of being isolated
  • Session cleanup logic doesn’t properly respect scope boundaries

Impact:

  • High severity - breaks core multi-session functionality
  • Users are unexpectedly logged out from other devices
  • Contradicts documented GoTrue behavior for multiple sessions

Configuration:

SESSIONS_SINGLE_PER_USER = false
REFRESH_TOKEN_ROTATION_ENABLED = true

Affected Components:

  • Session token generation and validation
  • Refresh token family management
  • Logout scope implementation
  • Multi-session isolation logic

This issue prevents reliable use of multi-device authentication and affects any application relying on independent sessions across multiple devices.

About this issue

Most upvoted comments

@Preetam7064 not sure about it working in react native apps. I will say that the feature was technically introduced in auth-js v.2.39.0, so if you were doing a package version override or something in that project, it could’ve been working even though you only had supabase-js v2.20.0.

@Preetam7064 ok, wow. I should’ve thought to ask what version you’re on. That feature wasn’t part of supabase-js until v2.27.0

@patilrush9 what supabase-js version are you on?

We are encountering an unexpected behavior with user sessions when using Supabase Authentication, specifically related to multi-device logins and session invalidation.

Observed Scenario:

A user logs into our application via an Android app. The same user also logs into the application via our website. The user then logs out only from the website. Unexpected Behavior:

After logging out from the website, the active session for the Android app (which was not logged out) becomes invalid. Subsequent API calls from the Android app that require an authenticated session (e.g., get user details from session api) fail with the following error:

{ “code”: 403, “error_code”: “session_not_found”, “msg”: “Session from session_id claim in JWT does not exist” } This occurs even when we explicitly use supabase.auth.signOut({ scope: “local” }) on the website, which we understood should only expire or remove the token from that specific local session (the website).

Analysis Through our analysis of the authentication flow, we’ve identified two primary issues:

Shared Session/Token Across Multiple Devices: When a user logs in from multiple devices (e.g., Android app and website), it appears they are using the same underlying session and token across all devices. This is contrary to expected multi-session management where each login should ideally yield a distinct, independent session. Global Session Invalidation on Local Logout: The supabase.auth.signOut({ scope: “local” }) function is not behaving as expected. Instead of only affecting the local website session, it seems to be invalidating the global session, thereby making the token used by the active Android app session invalid, even though the user did not explicitly log out from the app. Impact This issue is critical as our Python backend applications also rely on these tokens for user authentication. When a user’s session is unexpectedly invalidated from the website, any active requests from their Android app (from which they did not log out) also fail, leading to a broken user experience and 403 errors in our backend logs for what should be valid requests.

We are seeking guidance or a solution to ensure that:

Each login creates an independent session/token. supabase.auth.signOut({ scope: “local” }) indeed performs a local logout without affecting other active sessions.

Can you and @Preetam7064 verify if two different sessions are being created in your auth schema > sessions table when you login as the same user across two devices?

Assuming there is a session created for each login, can you then do the local logout on one device, then check to see if only that session was removed from the sessions table?

Understood! Thanks for your time and help. Appreciate it.

Exactly!

Since you confirmed that:

  • scope: 'local' keeps sessions independent
  • Default signOut() terminates all sessions (as designed)

Our fix of changing the JavaScript client default from 'global' to 'local' should solve the multi-session issue while maintaining backward compatibility for those who explicitly want global logout.

This would make JavaScript consistent with Dart/Kotlin clients and prevent accidental global logouts.

Am I right here?

It would; but it remains to be seen if the team wants to introduce that breaking change.

I didn’t realize the other clients had a different default - I’m just living in the javascript world here.

To be clear: in a global scope scenario signOut, sessions will temporarily still exist in the other devices - it’s just that the refresh tokens will be revoked, and, I believe, the sessions from the auth.sessions table will be removed.