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:
- Configure GoTrue with
SESSIONS_SINGLE_PER_USER = falseto enable multiple sessions - Login on Device A using
supabase.auth.signInWithPassword() - Login on Device B using the same credentials with
supabase.auth.signInWithPassword() - Verify both devices have active sessions by calling
supabase.auth.getSession()on both - On Device A, call
supabase.auth.signOut({ scope: 'local' }) - On Device B, call
supabase.auth.getSession() - 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 AgetSession()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
- Original URL
- State: open
- Created a year ago
- Comments: 30
@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?
Can you and @Preetam7064 verify if two different sessions are being created in your
authschema >sessionstable when you login as the same user across two devices?Assuming there is a session created for each login, can you then do the
locallogout on one device, then check to see if only that session was removed from thesessionstable?Understood! Thanks for your time and help. Appreciate it.
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.sessionstable will be removed.