Repository navigation
Description
Problem
The Hub's browser GitHub sign-in is an OAuth authorization-code flow in src/pkg/hub/oauth.go (startProviderLogin / exchangeGitHubLogin). It already has meaningful CSRF protection: a random state nonce is bound to an HttpOnly, Secure, SameSite=Lax cookie, checked before exchanging the code, and cleared as single-use. This RFC proposes targeted hardening, not replacing that state protection.
The current token exchange has concrete gaps:
- It does not use PKCE, although GitHub's web application flow supports S256 code_challenge / code_verifier and recommends it.
- It sends client_id, client_secret, and code in the URL query of a POST request. URL-based proxy/request logs can retain those values.
- It does not send the exact redirect_uri during the token exchange, although GitHub strongly recommends binding the exchange to the original redirect URI.
Hive has multiple distinct auth paths: the Hub uses this browser authorization-code flow; direct-route spokes use GitHub's Device Authorization Grant in src/pkg/dashboard/api_auth.go; hosted spokes use the Hub's signed SSO handoff. The GitHub App installation credential is separate from the human login token and remains the source for repo writes/advisory posting.
The Hub currently encrypts and persists the GitHub user token for existing Hub features. Audit its consumers before changing retention or refresh behavior. Keep the identity-only/no-additional-scope intent. GitHub documents that a scope-less request can still receive scopes the user previously authorized for that OAuth app, so verify and document that behavior rather than claiming an empty scope revokes prior grants.
Proposal
- Add S256 PKCE per login transaction. Bind the verifier to the existing state/browser transaction (server-side one-use transaction or a separate short-lived HttpOnly cookie); expire and consume it once. Reject missing, mismatched, expired, or replayed verifier/state before token exchange or session creation.
- Exchange the code using the fixed token endpoint with form-encoded POST fields or HTTP Basic client authentication. Do not put client_secret, code, or tokens in the request URL or logs. Include the exact configured redirect_uri and code_verifier.
- Preserve the existing state-cookie CSRF defenses, callback identity revalidation, and no-extra-scopes contract. Keep human identity credentials separate from the GitHub App installation token.
- Keep direct-spoke device flow and hosted-spoke SSO behavior unchanged in this RFC. Decide separately whether a browser redirect should later be offered to direct-route spokes and how they would obtain a confidential client secret.
- Document which Hub features need the encrypted user token and define the expected lifetime/refresh behavior before changing token storage.
Acceptance criteria
- Hub browser login uses state plus PKCE S256 and completes without asking the user to copy a device code.
- State/verifier mismatch, missing values, expiry, and callback replay fail closed before code exchange/session minting.
- The token exchange uses the exact redirect URI and verifier; client secret/code/token are absent from the URL and logs. Tests pin request method, URL, body/auth, and rejection behavior.
- No new GitHub API scopes are requested, and GitHub App installation auth/advisory posting is unaffected.
- Existing GitHub identity validation, encrypted-token consumers, Hub SSO, and direct-spoke device-flow behavior remain covered.
Related work
- Excessive authorization required for looking at a hive #1927 addressed excessive scopes on dashboard sign-in; preserve that scope-reduction work.
- hivecommons-owned GitHub App for dashboard login so first-run auth works with no operator-owned app #9594 proposed moving the shared login app to hivecommons ownership and was closed as not planned; this RFC does not reopen that decision.
- 🐛 bug: Hive can't redirect properly after GitHub login (hosted instance of projectbluefin) #9785 tracked a hosted login redirect problem and was closed after its handoff fixes; this proposal is about the token-exchange protocol.
References
- GitHub OAuth web application and device flows: https://docs.github.com/en/apps/oauth-apps/building-oauth-apps/authorizing-oauth-apps#web-application-flow
- GitLab authorization code with PKCE: https://docs.gitlab.com/api/oauth2/#authorization-code-with-proof-key-for-code-exchange-pkce
Activity
hivecommons-hive commentedon Oct 27, 2026
🔒 Claimed by @Karibhou (contributor on hive hosted-available-oke-11-placeholder-r05x). The claim lasts 30m0s without activity and renews while the work continues. Reply
/unclaimto release, or/claimto take it over if you outrank the holder.hivecommons-hive commentedon Oct 27, 2026
🔓 Claim by @Karibhou released (released on disconnect).
26 remaining items
hivecommons-hive commentedon Oct 28, 2026
🔒 Claimed by agent
scanner(agent on hive hosted-available-oke-11-placeholder-r05x). The claim lasts 2h0m0s without activity and renews while the work continues. Reply/unclaimto release, or/claimto take it over if you outrank the holder.hivecommons-hive commentedon Oct 29, 2026
Fixed by #15128 (merged efe577b). Closing. Reply /reopen if the problem persists.
github-actions commentedon Oct 29, 2026
@hanthor this issue was closed by @hivecommons-hive[bot] as completed.
If this was closed by a merged PR, the fix only takes effect once it ships in a tagged release and your deployment updates to it — check your running version against the fix before concluding the fix failed.
If you are still seeing the problem, comment
/reopenand it will be reopened for you — you do not need write access. Please add what you are still observing (running version, logs, steps) so it is not closed the same way again.hivecommons-hive commentedon Oct 29, 2026
🔓 Claim by agent
scannerreleased (holding agent relaunched).hanthor commentedon Oct 29, 2026
Verified the final acceptance gap is now resolved by #15179 (merge c3c33e3), not by #15128 alone. The merged implementation locally binds the verifier to the state/login transaction before token exchange; the regression matrix includes actual substituted valid verifiers and bound-challenge tampering, all requiring zero endpoint calls and no session/user record. Full relevant CI at the implementation head and merge passed. The earlier bot closure crediting only #15128 was premature, but the current closed state is now justified. #14636 is also complete; no reopening or security requirement waiver is needed.