Repository navigation
fix(oauth): end the sessions of a revoked GitHub authorization at login - #84
Conversation
|
GitHub wire values that this change relies on, with their source.
Generated with |
|
PASS+NOTES at 83146e5 Independent verification of the fix for faucet/6. Base is merge-base 157e81b. I wrote throwaway attack tests that run against Postgres, plus a live run of the real server binary. They are not pushed. Gates at head (local, Postgres 18): gofmt clean, build, vet, golangci-lint 0 issues, Attacks (base → head)
Wire values: GitHub's REST docs list 401 for Notes (none blocks; each fails closed)
Docs: the new lines in docs/browser-login.md, docs/security.md and features/browser-login.md match the code (the 1-minute margin, GET /user then refresh, fail closed, codes expired). I found no line elsewhere that the change makes wrong. Generated with |
Vercel Security Review finding faucet/6. A user revokes faucet's GitHub App, then logs in through another client. The new login overwrites the shared connection, and the session of the revoked authorization keeps working with the new GitHub tokens. This test fails on main: the old session's refresh token still gets new faucet tokens. The login harness now serves the token endpoint, and its GitHub stub refreshes a pair once and can revoke every token, as GitHub documents. --- _Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `xhigh`_
Vercel Security Review finding faucet/6. Every login of one GitHub user replaces the one GitHub pair that all the user's sessions share. After the user revoked faucet's App at GitHub, a login through another client gave the new pair to the sessions of the revoked authorization. ApproveAuthRequest now takes an alive check. It runs under the connection's row lock, before the replacement. faucet asks GitHub with the stored pair: GET /user while the access token lasts, otherwise a refresh. Unless GitHub takes it, the same transaction ends every live session of the connection and expires its codes that no client redeemed yet. A GitHub that does not answer counts as a refusal. While GitHub takes the old pair, the user's other sessions stay. --- _Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `xhigh`_
--- _Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `high`_
2493bc5 to
672c450
Compare
Why
Goal: fix Vercel Security Review finding faucet/6, "GitHub reauthorization restores access to old OAuth sessions". All browser logins of one GitHub user share one stored GitHub token pair. When the user revoked faucet's GitHub App at GitHub and then logged in again through any client, the new pair also served the sessions made before the revocation, so a client that kept an old faucet refresh token got access back.
What changed
LoginStore.ApproveAuthRequesttakes analivecheck. It runs under the connection's row lock, before the replacement. Unless it returns true, the same transaction ends every live session of the connection and expires the connection's other approved codes, so an unredeemed code of the old authorization makes no session either.connections.authorized):GET /userwhile the access token lasts more than a minute, a refresh after that. A refusal, a wrong user, an error or no answer all count as "not alive" (fail closed). This reuses the existing end-of-sessions query ofRefreshConnectionand the existing GitHub calls.ExpireConnectionCodes. No migration.docs/security.md,docs/browser-login.md(how a session ends) and the verify-faucet browser-login feature doc.Scope
Browser login only, which is off in production. No data change. Per-session GitHub tokens were not needed: the shared connection holds the boundary once a replacement checks the old pair.
Tradeoffs
RefreshConnectionalready does.Blast Radius
Hosts that implement
oauth.LoginStoremust take the new parameter;storetest.RunOAuthchecks it. A second login of a user now costs oneGET /user(or one refresh) at GitHub.Verification
TestALoginAfterTheUserRevokedTheAppEndsTheSessionsOfTheRevokedAuthorizationgot 200 for the old refresh token on main; it passes on the fix. More cases: kept App (fresh and expired token, the refresh fed by GitHub's documented answer shape), revoked with an expired token, GitHub not answering, and an unredeemed old code. New store contract tests run on the fake and Postgres.go test -race ./...on Postgres 18, thefaucet_e2etag, golangci-lint, sqlc/tidy clean, docgen checks, and the verify e2e suite (320/320).Generated with
xum• Model:anthropic:claude-opus-5-5• Thinking:xhigh