Skip to content

[scanner] hub-auth: add S256 PKCE verifier cookie to Hub GitHub login #14633

Closed

Description

@hivecommons-hive

Part of #14598

Target branch: v6

Scope

Add S256 PKCE to the Hub's GitHub browser login. In startProviderLogin (src/pkg/hub/oauth.go:561), for the non-OIDC branch (oauth.go:601-608) generate a 32-byte random code_verifier, set it in a separate short-lived cookie (HttpOnly, Secure, SameSite=Lax, host-scoped, TTL oauthStateTTL at oauth.go:1410, mirroring the state cookie at oauth.go:577-591), and add code_challenge=<S256>&code_challenge_method=S256 to the authorize URL. In the callback (state check at oauth.go:726-737, exchange call at :791) read the verifier cookie, clear it immediately (single use), and pass code_verifier to exchangeGitHubLogin (oauth.go:932) in the form body. Missing, empty, malformed or expired verifier cookie must fail closed with 400 before the code exchange or any session is minted. Do not change the state nonce format or its cookie.

Decision taken by hive: bind the verifier via a separate HttpOnly cookie, not a server-side transaction store; the Hub has no existing transaction table for logins and a cookie matches the existing state design and is additive. Logins in flight during deploy lack the cookie and fail closed with the existing "please start the login again" message; that is acceptable per the RFC's fail-closed requirement.

Acceptance criteria

  • Authorize redirect includes code_challenge (S256 of the verifier) and code_challenge_method=S256; scope stays empty.
  • Token exchange sends the matching code_verifier.
  • Missing/mismatched/expired/replayed verifier or state returns 400 and performs no token exchange (test asserts the fake token endpoint receives zero requests) and mints no session.
  • Verifier cookie is cleared on callback success and failure.
  • OIDC providers and device flow (src/pkg/dashboard/api_auth.go) unchanged.

Likely files

  • src/pkg/hub/oauth.go
  • src/pkg/hub/oauth_provider_login_test.go, oauth_login_shortcircuit_test.go, oauth_state_encoding_test.go (new PKCE tests may go in a new oauth_pkce_test.go)

Depends on the form-POST token exchange child (needs the body-based code_verifier field).

— hive: agent=scanner backend=copilot model=claude-fable-5.1 copilot=1.0.88

Activity

  1. added
    help wantedDenotes an issue that needs help from a contributor. Must meet "help wanted" guidelines.
    on Oct 27, 2026
  2. hivecommons-hive commented on Oct 27, 2026

    @hivecommons-hive
    ContributorAuthor

    🔒 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 /unclaim to release, or /claim to take it over if you outrank the holder.

  3. hivecommons-hive commented on Oct 27, 2026

    @hivecommons-hive
    ContributorAuthor

    🔓 Claim by @Karibhou released (lease revoked).

  4. hivecommons-hive commented on Oct 28, 2026

    @hivecommons-hive
    ContributorAuthor

    Not dispatching a duplicate this cycle: #14701 (✨ feat(hub): add S256 PKCE verifier cookie to the Hub GitHub login, base v5) already implements this scope and is parked on stage/085-needs-decision awaiting a maintainer ruling. Once that PR lands or is declined, this issue either closes (forward-merge to v6) or becomes actionable again.

    — hive: agent=scanner


    🐝 Hive Agent: scanner | Instance: hosted-available-oke-11-placeholder-r05x | SHA: unknown

  5. added
    hive/likely-doneHive verified that a merged PR references or claims this issue; pending confirmation
    and removed on Oct 28, 2026
  6. hivecommons-hive commented on Oct 28, 2026

    @hivecommons-hive
    ContributorAuthor

    Verified once on v6 @ 7ea5d9a3d: #14701 (merged as 2b120c6) fully resolves this issue.

    • PKCE verifier cookie: startProviderLogin mints a 32-byte base64url verifier (oauthPKCEVerifier, src/pkg/hub/oauth.go:1475). It stores the verifier in the hive_oauth_pkce cookie (oauth.go:617-625: HttpOnly, Secure, SameSite=Lax, host-scoped, MaxAge = oauthStateTTL).
    • S256 challenge: the authorize URL carries code_challenge=pkceS256Challenge(verifier)&code_challenge_method=S256 (oauth.go:627-628). pkceS256Challenge is BASE64URL(SHA256(verifier)) (oauth.go:1484).
    • Fail-closed callback: the verifier is read and cleared on every outcome (oauth.go:746-747). A missing or malformed verifier is rejected before the exchange (oauth.go:825-829). code_verifier is sent in the form body (oauth.go:986).
    • Tests: src/pkg/hub/oauth_pkce_test.go covers the challenge, the form-body verifier, the missing/empty/malformed/short matrix, a bad state clearing the verifier, and replay.

    Closing as completed. This unblocks #14636. The remaining verifier contract cases for #14636/#14598 are in the follow-up PR for #14598.

    — hive: agent=scanner


    🐝 Hive Agent: scanner | Instance: hosted-available-oke-11-placeholder-r05x | SHA: unknown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent/scannerCreated or modified by the scanner agenthelp wantedDenotes an issue that needs help from a contributor. Must meet "help wanted" guidelines.hive/likely-doneHive verified that a merged PR references or claims this issue; pending confirmation

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions