8000 fix(auth): don't revive a session that ended during a refresh by adeelahmad · Pull Request #198 · adeelahmad/lense · GitHub
[go: up one dir, main page]

Skip to content

fix(auth): don't revive a session that ended during a refresh - #198

Merged
adeelahmad merged 1 commit into
mainfrom
claude/project-thread-qt650x-refresh-race
Oct 6, 2026
Merged

adeelahmad merged 1 commit into
mainfrom
claude/project-thread-qt650x-refresh-race

Conversation

@adeelahmad
Copy link
Copy Markdown
Owner

Requested by Adeel · project thread

Description

Before: auth.refresh_session read the login session, checked the account, and then rotated it in a separate step (UPDATE the old row, CREATE the new one). If a sign-out, password change, passkey removal or reuse detection deleted the session in between, the CREATE brought it back under the new token. session_active then stayed true for a session that should have ended. Someone holding a stolen refresh token and refreshing repeatedly could hit that gap.

After: the rotation is one transaction that fails when the old row is no longer there, and the refresh answers "session ended". An ordinary refresh behaves as before.

Motivation and Context

This answers threat-model question Q39: a token minted while its grant or session is being revoked must not outlive the revocation (part of P-AUTH-REQ). OAuth grants and API tokens already held. This was the one race left.

Steps to reproduce (if appropriate):

test_a_refresh_racing_a_sign_out_does_not_bring_the_session_back signs out between the read and the rotation. It fails on main and passes here. The other auth, account and passkey tests still pass.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change; ! in the title)

Checklist:

  • The title is a Conventional Commit.
  • My code follows the code style of this project (make hooks checks it on commit).
  • I added or updated tests.
  • My change requires documentation updates, and I have updated docs/ accordingly.
  • Users need more than the title to understand it, so I wrote it under ## Unreleased in CHANGELOG.md.

🤖 Generated with Claude Code

https://claude.ai/code/session_01W42z4FbekWr33b6791svQQ


Generated by Claude Code

refresh_session read the session, then rotated it in a second step, so a
sign-out, password change or passkey removal landing in between left a new
token for an ended session. Rotating now fails when the old token is gone.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01W42z4FbekWr33b6791svQQ
@adeelahmad adeelahmad self-assigned this Oct 6, 2026
@adeelahmad
adeelahmad merged commit 893011b into main Oct 6, 2026
5 checks passed
@adeelahmad
adeelahmad deleted the claude/project-thread-qt650x-refresh-race branch October 6, 2026 10:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

0