Repository navigation
π fix: let device-flow sign-in and hive_session requests through the proxy - #15882
Conversation
|
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 |
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. |
|
CI note β
Re-ran the failed job. DEFER β no code change needed. π Hive Agent: β hive: agent=scanner backend=copilot model=claude-fable-5.1 copilot=1.0.88 |
β¦proxy Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> Co-authored-by: hanthor <5840441+hanthor@users.noreply.github.com>
abaad54 to
e8e0ecb
Compare
|
Correction to the note above: a job rerun isn't available from this agent, so instead I rebased the branch onto current π Hive Agent: β hive: agent=scanner backend=copilot model=claude-fable-5.1 copilot=1.0.88 |
There was a problem hiding this comment.
Looks correct to me, and the trust-boundary claims in the body hold against the Go side at v5.
What I checked on the tree (not just the diff):
src/proxy/server.js:1011βPUBLIC_EXACT_POST_PATHS.includes(req.url.split('?')[0])is a true exact match; the siblingPUBLIC_POST_PATHSat:1010still usesstartsWith, so/api/gh-user-auth/startxand/api/gh-user-auth/otherkeep 401ing, as the new tests assert. The Go API already treats/api/gh-user-auth/*(except/logout) as public atsrc/pkg/dashboard/server.go:2418-2419, so the proxy was the only thing blocking device-flow start/poll.src/proxy/server.js:1015β a request admitted on thehive_sessioncookie still hasreq.hiveTokenVerified === false, so theproxyReqhook at:1029-1032removesX-Hive-Internalrather than injecting it. On the Go side the cookie is then resolved bysessionFromRequest+liveSessionRoleatserver.go:2150-2168; an unknown or revoked session leavestrusted=falseand falls through to the 401 at the end ofauthenticate(). So forwarding an arbitrary cookie value (hive_session=abc123in the test) grants nothing by itself β the proxy stops being a second, redundant gate and the real one remains.src/pkg/dashboard/session.go:223,274,294β the cookie is issuedSameSite=Lax, so a cross-site form POST does not carry it; the proxy's cookie-based pass-through does not open a CSRF path the Go API wasn't already exposed to.parseCookiesatserver.js:518returns a plain object, so the['hive_session']lookup is safe with a missing header.
The four new tests in api_internal_header.test.js:187-209 cover exactly the behaviours above (forwarded without X-Hive-Internal, exact-match-not-prefix, cookie pass-through). Nothing else in the diff.
β hive: agent=reviewer-2 backend=copilot model=claude-fable-5.1 copilot=1.0.88
There was a problem hiding this comment.
Decision needed: @clubanderson should decide whether the bundled proxy may forward mutating requests to the Go API on the strength of a hive_session cookie's presence alone (server.js:1015), delegating the only authentication of those mutations to pkg/dashboard authenticate().
Conclusion: the code does what the body says and I found no defect, but it relaxes the proxy's mutation gate β a trust surface β so an approver should sign it, not me.
What I verified in the tree (v5 @ base, plus this diff)
src/proxy/server.js:997(new) βPUBLIC_EXACT_POST_PATHSis matched withincludes(req.url.split('?')[0]), so/api/gh-user-auth/startxand/api/gh-user-auth/otherstill fall torequireAuth(server.js:710β 401). The test file asserts both. The existingPUBLIC_POST_PATHSline above it usesstartsWith; the new list deliberately does not.server.js:1015(new) β thehive_sessionbranch only callsnext(); it does not setreq.hiveTokenVerified.X-Hive-Internalis injected solely onDASHBOARD_TOKEN && req.hiveTokenVerified(server.js:1029-1032), and the new test checksinternal === nullfor the cookie case. So no owner-equivalent credential is minted for cookie traffic.parseCookiesexists atserver.js:518(shared with the terminal gates); the cookie name matchessessionCookieName = "hive_session"atpkg/dashboard/server.go:65.- Go side,
pkg/dashboard/server.go:2149-2168βsessionFromRequest+liveSessionRoleresolve the cookie against the live allowlist on every request; a revoked/unknown/garbage session leavestrusted=falseand the handler 401s atserver.go:2233-2236./api/gh-user-auth/*except/logoutis already in Go's public allowlist (server.go:2418-2419), sostart/pollwere only ever blocked by the proxy. - Cookies are set
SameSite=Lax(pkg/dashboard/session.go:223,274,294), so a cross-site form POST does not carry the session.
Why a person should still decide
Before this change the proxy was a second, independent gate on every mutation (shared token or nothing). After it, any client that sends any hive_session= value reaches the Go API's authenticate() for mutations, and the Go middleware is the sole gate. That is defensible β the Go path is designed for exactly this and fails closed β but it is a deliberate reduction in defense-in-depth on the proxy, and /poll is now reachable unauthenticated for anyone who can guess or obtain a flow_id. I did not evaluate flow_id entropy; that is the one open question I could not settle from the diff.
No code change requested. I have not approved or altered anything.
β hive: agent=reviewer backend=copilot model=claude-fable-5.1 copilot=1.0.88
|
Needs a decision, not a merge:
Head: verdict requires_human @e8e0ecb, 62/62 checks green, DCO yes, soak 0s of 10m0s. What to do: approve this head ( How to release it:
Clear the cause and the hive re-evaluates on its next pass; the stage moves to |
clubanderson
left a comment
There was a problem hiding this comment.
Decision: approve this exact head for the device-flow/session pass-through fix.
The proxy may forward these requests to the Go API; cookie presence is transport admission, not proof of authentication. I checked the proxy diff and the backend authentication at this head: the two device-flow paths use exact matching; session-only requests do not receive X-Hive-Internal; client identity headers are stripped; the Go API resolves the session server-side, rechecks its live allowlist role, and rejects unauthenticated protected requests. The existing Go API remains the authentication and authorization boundary.
Proceed through the normal Hive CI, hold and soak gates. This approval does not authorize weakening any of them or activating a rollout.
|
LGTM label has been added. DetailsGit tree hash: 88ed7da54a0aa161843601dc52999e950962fb65 |
|
hive/awaiting-ci: build-and-test failure was in dashboard nav_count_delta.test.js (not this proxy-only diff) β v5 was red at 5355cbd and fixed by cccbf34; merged v5 into the branch to re-run. CI pending β sweep will merge when green. π Hive Agent: β hive: agent=scanner backend=copilot model=claude-fable-5.1 copilot=1.0.88 |
|
Thank you for your contribution! Your PR has been merged. We'd love to hear how your experience was: share feedback |
The proxy rejected every mutating request without the shared dashboard token, so device-flow sign-in on direct-route spokes (POST /api/gh-user-auth/start and /poll, made before the visitor has any credential) always 401'd. Users already holding a
hive_sessioncookie were likewise refused on every mutation. The Go API already authenticates both cases itself.Trust boundary:
/api/gh-user-auth/startand/api/gh-user-auth/pollare admitted (no prefix match;/startxstill 401s)./pollonly completes a flow for the holder of its flow_id.hive_sessionrequests are passed through but never getX-Hive-Internal, sohiveTokenVerifiedstays false. The cookie is SameSite=Lax.Tests added to api_internal_header.test.js; changelog fragment added. v6 receives this via the normal v5βv6 forward-merge.
Closes #15872
β hive: agent=scanner backend=copilot model=claude-fable-5.1 copilot=1.0.88 requested_by=@hanthor