AI & Agent Dev Bug Sandbox logo
AI & Agent Dev Bug Sandbox
Back to Radar

Sessions_inactivity_timeout Not Enforced At Refresh_token Grant

The `sessions_inactivity_timeout` configuration is accepted and persisted by the Supabase Auth management API, but the refresh token grant does not check the session's last activity time, allowing stale refresh tokens to be redeemed indefinitely past the configured inactivity threshold.

highConfidence 82%GoTrue

Origin Analysis

The refresh token grant handler in GoTrue only validates the session's overall timebox and revocation status, but omits the synchronous check against `sessions_inactivity_timeout`; this is a design gap where inactivity enforcement relies solely on an asynchronous reaper instead of being enforced at the token exchange point.
1. Set `sessions_inactivity_timeout` to e.g. 60 seconds via `PATCH /v1/projects/{ref}/config/auth`. 2. Verify the value is persisted via `GET /v1/projects/{ref}/config/auth`. 3. Authenticate a user to obtain a refresh token. 4. Wait longer than the configured timeout without any session activity. 5. Exchange the stale refresh token at `POST /auth/v1/token?grant_type=refresh_token`. 6. Observe HTTP 200 and new tokens are issued, indicating the timeout was not enforced.

Fixing Code Block

Edge Case Audit

This change may cause unexpected logouts if the LastActiveAt/UpdatedAt timestamp is not comprehensively updated on all user activity, especially for long-lived access token usage. Concurrent refresh requests could race and both pass if the timestamp is not updated atomically within the same transaction. Enforcing this synchronously after a config change may immediately invalidate all existing sessions whose timestamps are older than the new threshold. Rollback strategy: set `sessions_inactivity_timeout` to 0 or disable the check via a feature flag. Before enabling, ensure every authenticated request updates the session's activity timestamp to avoid false positives.

Ecosystem Topology