Skip to content

Multi-Session Authentication Bug: Local Logout Invalidates All Sessions #2036

Open
@omkargade04

Description

@omkargade04

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions