You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[scanner] hub-auth: send GitHub token exchange as form POST with redirect_uri (no secrets in URL) #14631
exchangeGitHubLogin (src/pkg/hub/oauth.go:932-940) builds the token request with client_id, client_secret and code in the URL query of a POST to defaultGHTokenURL (src/pkg/hub/oauth.go:47, used at :936), so URL-based proxy/request logs can retain them. Move them into a form-encoded POST body (Content-Type: application/x-www-form-urlencoded) to the fixed token endpoint, and add the exact redirect_uri (oauthRedirectURI(), src/pkg/hub/saas_auth.go:371, the same value sent in the authorize redirect at oauth.go:603-604). Keep Accept: application/json, the response size cap, and the rest of the flow unchanged. No new scopes (authorize URL keeps scope=). OIDC path (p.AuthCodeURL, oauth.go:626) is untouched.
Decision taken by hive: use form-body client credentials (not HTTP Basic); it is GitHub's documented shape and the smallest diff.
Acceptance criteria
Token request has an empty URL query; client_id, client_secret, code, redirect_uri are in the form body only.
Tests pin method, URL (fixed endpoint, no query), headers, body fields, and failure handling (non-200/ invalid JSON/ empty access_token).
Secret/code/token never appear in logged errors (check the s.logger.Warn("OAuth token exchange failed", "error", err) path at ~oauth.go:947 does not echo the URL with query).
Existing callback/state tests (src/pkg/hub/oauth_*_test.go) still pass; GitHub App installation auth and device flow unaffected.
Folded finding. This was filed as a separate issue, but 3 open agent-filed issues already cite src/pkg/hub/oauth.go, so it was folded into the oldest of them instead of opening another. Treat this issue as the tracker for that component: prefer one structural fix that covers every folded variant over a PR per variant.
[scanner] hub-auth: pin Hub login contract with fail-closed and no-secret-in-URL/log tests
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.
Activity
hivecommons-hive commentedon Oct 27, 2026
Folded finding. This was filed as a separate issue, but 3 open agent-filed issues already cite
src/pkg/hub/oauth.go, so it was folded into the oldest of them instead of opening another. Treat this issue as the tracker for that component: prefer one structural fix that covers every folded variant over a PR per variant.[scanner] hub-auth: pin Hub login contract with fail-closed and no-secret-in-URL/log tests
Part of #14598
Target branch:
v6Scope
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 (captures.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 constantdefaultGHTokenURL(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
Likely files
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
github-actions commentedon Oct 27, 2026
Closed by #14683 (merged to
v6).