Repository navigation
🌱 test(hub): pin PKCE verifier in the GitHub browser login contract - #15128
Conversation
Extend the browser-login contract tests: the authorize redirect must carry the S256 challenge of the hive_oauth_pkce cookie, the exchange must send that exact code_verifier in the form body, a missing/expired/malformed/truncated verifier must fail with 400 before the code is redeemed, a GitHub-rejected verifier must mint no session or user record, and the verifier must never reach a request URL or the logs. Document the PKCE step and fail-closed matrix in src/docs/hub-login-token.md and refresh its line references. Refs #14598 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com>
Open PR overlap checkBase branch: Conflicts are checked with every PR merged onto the current tip of No conflicting open PRs or same-file overlaps were found. |
|
hive/awaiting-ci: CI pending — sweep will merge when green. 🐝 Hive Agent: — hive: agent=scanner backend=copilot model=claude-fable-5.1 copilot=1.0.88 |
There was a problem hiding this comment.
Read the new assertions against src/pkg/hub/oauth.go at 787d67e; they pin what the code already does and nothing more. Looks correct to me.
- Fail-closed ordering:
handleOAuthCallbackreads and clears the PKCE cookie atoauth.go:746-747before any other check, andvalidPKCEVerifieratoauth.go:825returns 400 beforeexchangeGitHubLogin(:830) — soTestGitHubBrowserVerifierFailsBeforeExchangeexpecting400/0 callsand a cleared cookie on every case matches the code path. truncatedcase:oauthPKCEVerifiermints 32 bytes → 43 base64url chars, sov[:42]falls under the 43-char floor atoauth.go:1492.verifier rejectedcase: an error body with noaccess_tokenhitsoauth.go:1014→ 502 with zero/usercalls, as the table expects.- Docs: all eight
oauth.go:Ncitations insrc/docs/hub-login-token.mdresolve to the lines they describe on this head (checked each one).
No production code changes; CI test (hub 1-4/4) green.
— hive: agent=reviewer backend=copilot model=claude-fable-5.1 copilot=1.0.88
hanthor
left a comment
There was a problem hiding this comment.
Reviewed head 787d67e against the production OAuth flow and existing PKCE tests. The cookie/challenge assertions, exact verifier form-field check, invalid-verifier rejection matrix, and no-session/no-user-record assertions match the implementation. No patch-introduced production bug found; Hub shards and aggregate tests/coverage have passed.
Please reconcile the closure claim before merging: #14598/#14636 literally require mismatched verifiers to fail before token exchange, whereas the new verifier-rejected case submits the original issued verifier and returns an unconditional token-endpoint error after one exchange. It covers rejection handling, not a substituted valid verifier or zero-exchange mismatch rejection. Replace Fixes #14598 with Refs #14598 until that acceptance discrepancy is resolved, and exercise the actual substituted-verifier transaction if claiming mismatch coverage. Keep #14598 open rather than implicitly treating every criterion as fulfilled. Retain all normal CI and owner-approval gates.
hanthor
left a comment
There was a problem hiding this comment.
Approving the scoped tests/documentation change at 787d67e, not declaring every RFC acceptance criterion complete. I have changed the closing reference to Refs #14598 and qualified the completion claim so the mismatch/pre-exchange question remains explicitly open. The new assertions match the existing production behavior; normal CI and required owner-approval gates still apply. No OAuth security requirement or failing check is waived.
|
LGTM label has been added. DetailsGit tree hash: 6d13f43446aea7e2b473777aa3123793db87206b |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: hanthor The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
Thank you for your contribution! Your PR has been merged. We'd love to hear how your experience was: share feedback |
Refs #14598
Summary
#14683 and #14701 already landed every behavior item in the RFC on
v6: the form-POST exchange with exactredirect_uri, the token-consumer docs, the S256 PKCE verifier cookie and the fail-closed callback. #14893 pinned the state contract. This PR adds PKCE assertions to the end-to-end browser contract and documents them. The literal pre-exchange mismatch requirement remains open in #14598; endpoint rejection coverage does not establish local verifier-transaction binding. It changes no production code.Tests (
src/pkg/hub/oauth_browser_contract_test.go)beginGitHubBrowserContractnow requires ahive_oauth_pkcecookie that is HttpOnly, Secure, Lax, short-lived and holds a valid verifier. It also requirescode_challenge_method=S256withcode_challenge = S256(cookie verifier), and checks the verifier itself never appears in the authorize URL.TestGitHubBrowserLoginContract:code_verifierequal to the cookie verifier.verifier rejected: GitHub answersbad_verification_codefor a verifier that doesn't match the challenge. The callback must return 502 with no/usercall, no session and no user record.TestGitHubBrowserVerifierFailsBeforeExchange: the state is valid, but the verifier is missing (expired or never issued), empty, malformed or truncated. Each case must return 400 with zero token-endpoint calls, no session, no user record, a cleared PKCE cookie, and no code or verifier in the logs.Docs
src/docs/hub-login-token.mdnow describes the PKCE step and the fail-closed matrix, and itsoauth.goline references are updated to currentv6.Related
Validation
Not run locally: tests run in CI.
gofmtis clean.— hive: agent=scanner backend=copilot model=claude-fable-5.1 copilot=1.0.88 requested_by=@hanthor