Skip to content

[scanner] hub-auth: pin Hub login contract with fail-closed and no-secret-in-URL/log tests #14636

Closed

Description

@hivecommons-hive

Part of #14598

Target branch: v6

Scope

Regression-test lane after the exchange and PKCE changes: add table-driven tests in src/pkg/hub that pin the whole browser login contract using an httptest fake of the GitHub token and user endpoints: authorize redirect shape (empty scope, redirect_uri, state, code_challenge/S256), token request (method POST, no URL query, form body fields, no secrets in the URL), and fail-closed matrix (no state cookie, state mismatch, missing/mismatched/expired verifier, replayed callback after cookie cleared) asserting zero token-endpoint calls and no session cookie set. Also assert log output (capture s.logger) never contains the client secret, code, or access token. Keep existing identity validation (isValidName, oauth.go ~:990) and encrypted-token persistence (oauth.go:847) covered. The token endpoint is the package constant defaultGHTokenURL (oauth.go:47); if the tests need an override seam, add the smallest test-only injection.

Decision taken by hive: tests only plus a minimal seam; no production behavior change.

Acceptance criteria

  • Tests cover every case above and fail if secrets reappear in the URL or logs.
  • GitHub App installation auth, device flow and hosted SSO tests unchanged.

Likely files

  • src/pkg/hub/oauth_pkce_test.go (new), src/pkg/hub/oauth_provider_login_test.go
  • src/pkg/hub/oauth.go (test seam only, if needed)

Depends on both the form-POST exchange child and the PKCE child.

— 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

    Good first issue — superseded: hosted-available-oke-11-placeholder-r05x started working on this issue itself (claimed-by-hive, 2026-10-29T01:17:15Z), so the good first issue label has been removed. Thanks for looking! Other issues open to new contributors are listed on the relay page: https://hosted-kubestellar-hive-ojv6.hive.hivecommons.dev/contribute

  3. added
    good first issueDenotes an issue ready for a new contributor, according to the "help wanted" guidelines.
    on Oct 27, 2026
  4. 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.

  5. hivecommons-hive commented on Oct 27, 2026

    @hivecommons-hive
    ContributorAuthor

    🔓 Claim by @Karibhou released (lease revoked).

  6. 26 remaining items

  7. added
    hive/partially-addressedA merged PR addressed only part of this issue; remainder still actionable
    stage/010-actionableTriaged; eligible for the hive to pick up
    and removed on Oct 28, 2026
  8. hanthor commented on Oct 28, 2026

    @hanthor
    Contributor

    Follow-up from review of #15128: state/exchange tests and most PKCE assertions are now covered, but do not close this child as fully complete. The new verifier-rejected fixture submits the original verifier and unconditionally returns a GitHub error; it is endpoint-error handling, not an actual swapped valid-verifier transaction. The parent #14598 still literally requires mismatch rejection before exchange, while the implementation validates syntax locally and delegates challenge matching to GitHub. Preserve that discrepancy explicitly; do not weaken/re-pin tests to claim zero exchanges without production support. Keep the scope distinction between this tests-only child and any parent-level transaction-binding change.

  9. added
    hive/verified-openHive verified that a likely/already-done claim did not finish this issue; keep open for more work
    on Oct 28, 2026
  10. hivecommons-hive commented on Oct 28, 2026

    @hivecommons-hive
    ContributorAuthor

    Verified against v6 after #14893 and #15128. Covered in oauth_browser_contract_test.go / oauth_pkce_test.go: authorize shape (empty scope, redirect_uri, state, S256 challenge), form POST with no URL query or secrets, no-state-cookie / state-mismatch / missing-state / missing, empty, malformed and truncated verifier failing before exchange with zero token calls and no session cookie, replay after cookie clear, identity validation, encrypted-token persistence, and log output free of secret/code/token.

    One gap remains: a valid but swapped verifier is not rejected locally. Production only checks verifier syntax and leaves challenge matching to GitHub, so the 'verifier rejected' fixture covers endpoint-error handling, not mismatch rejection before exchange. Asserting zero exchanges there would need a production change, which this tests-only child excludes, so no further test is added. Leaving open and not re-pinning to claim otherwise; the transaction-binding decision belongs to #14598.


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

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

  11. added
    stage/020-claimedClaimed by the scanner or a relay contributor
    and removed
    stage/010-actionableTriaged; eligible for the hive to pick up
    good first issueDenotes an issue ready for a new contributor, according to the "help wanted" guidelines.
    on Oct 29, 2026
  12. hivecommons-hive commented on Oct 29, 2026

    @hivecommons-hive
    ContributorAuthor

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

  13. hivecommons-hive commented on Oct 29, 2026

    @hivecommons-hive
    ContributorAuthor

    Closing as completed on v6. The remainder @hanthor flagged (a real swapped valid-verifier transaction, not endpoint-error handling) is now pinned because #15179 (merged 2026-10-29, v6) binds the PKCE verifier to the login transaction before exchange: TestGitHubBrowserVerifierFailsBeforeExchange (src/pkg/hub/oauth_browser_contract_test.go) covers swapped valid / one-char-changed / max-length verifiers plus missing-or-expired, malformed and stripped-challenge cases, each asserting 400, zero token-endpoint calls, no session cookie, and no code/verifier in logs; TestPKCE_ReplayedCallbackIsRejected (oauth_pkce_test.go) covers replay after cookie clearing; #14893/#15128 cover state, exchange shape and no-secret-in-URL. The parent #14598 discrepancy (local syntax check vs GitHub-side matching) no longer exists, so no tests-only PR is needed. /unclaim


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

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

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/partially-addressedA merged PR addressed only part of this issue; remainder still actionablehive/verified-openHive verified that a likely/already-done claim did not finish this issue; keep open for more work

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions