You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug]: auth: sign-out answers 200 and clears the cookie when deleting the session fails, leaving the session valid #980
Security-sensitive (a session survives a sign-out the user saw succeed), severity: low. Found in an adversarial review of the auth 503 handling (#934, #968). The storage fault was simulated.
Runtime revision and environment
origin/main ba9f3204 (better-auth 1.7.6 from the lockfile), Node 26.10, macOS.
What happens
The auth mount turns Better Auth's 5xx/throws into 503 auth_unavailable and passes through anything below 500 (packages/auth/src/auth.tshandle, around line 237). Better Auth's /sign-out catches a deleteSession failure itself, logs it, and still answers 200 {"success":true} with cookie-clearing Set-Cookie. So when the session delete hits a storage error, the client is told it signed out, but the session row survives. Any copy of the token taken before sign-out (another tab or device, a captured cookie) stays valid until it expires. The documented "storage failure → 503" contract does not hold for sign-out.
Minimal reproduction
Sign in; CREATE TRIGGER fail_delete BEFORE DELETE ON session BEGIN SELECT RAISE(ABORT, 'simulated disk I/O error'); END on auth.sqlite; POST /api/auth/sign-out with the session cookie and a same-origin Origin; drop the trigger; send GET to an auth: true route with the old cookie.
sign-out 200 {"success":true} set-cookie: ['better-auth.session_token=; Max-Age=0; …', …]
/me with the "signed-out" cookie after storage recovers: 200 {"identity":{"userId":"…"}}
Observed with the simulated fault. Not verified: how often a real lock or full disk fails on the delete rather than on the rate-limit write that comes before it, which would already answer 503.
Suggested fix
For /sign-out (and /revoke-session(s)), have the mount confirm the session is gone before passing a success through, and answer 503 otherwise. Or raise the swallowed error upstream with Better Auth and document the gap meanwhile.
Activity
fix: host lease survives clock skew and fails closed; sign-out confir…