Skip to content

πŸ› fix: let device-flow sign-in and hive_session requests through the proxy - #15882

Merged
hivecommons-hive[bot] merged 3 commits into
v5from
scanner/fix-15872
Oct 31, 2026
Merged

hivecommons-hive[bot] merged 3 commits into
v5from
scanner/fix-15872

Conversation

@hivecommons-hive

Copy link
Copy Markdown
Contributor

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_session cookie were likewise refused on every mutation. The Go API already authenticates both cases itself.

Trust boundary:

  • Only the exact paths /api/gh-user-auth/start and /api/gh-user-auth/poll are admitted (no prefix match; /startx still 401s). /poll only completes a flow for the holder of its flow_id.
  • hive_session requests are passed through but never get X-Hive-Internal, so hiveTokenVerified stays false. The cookie is SameSite=Lax.
  • All other unauthenticated mutations still return 401.

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

@kubestellar-prow kubestellar-prow Bot added dco-signoff: yes Indicates the PR's author has signed the DCO. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Oct 30, 2026
@hivecommons-hive

Copy link
Copy Markdown
Contributor Author

hive/awaiting-ci: CI pending β€” sweep will merge when green.


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

β€” hive: agent=scanner backend=copilot model=claude-fable-5.1 copilot=1.0.88

@github-actions

Copy link
Copy Markdown
Contributor

Open PR overlap check

Base branch: v5

Conflicts are checked with every PR merged onto the current tip of v5, so a PR that only needs a rebase is not reported as conflicting with its siblings.

No conflicting open PRs or same-file overlaps were found.

@hivecommons-hive hivecommons-hive Bot added author/hive This repository's own hive (the App or one of its agent lanes) authored this PR dco All commits are DCO signed-off role/trusted Author is trusted for unattended merge (trusted-author role or registry/claim tier in require_tiers) stage/050-review-pending Review swarm requested; awaiting a verdict for the current head labels Oct 30, 2026
@hivecommons-hive

Copy link
Copy Markdown
Contributor Author

CI note β€” docker (contributor) failure on abaad54 is an infrastructure flake, not caused by this PR:

Re-ran the failed job. DEFER β€” no code change needed.


🐝 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

…proxy

Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com>
Co-authored-by: hanthor <5840441+hanthor@users.noreply.github.com>
@hivecommons-hive hivecommons-hive Bot added stage/070-fixing Hive-authored PR: CI red, changes requested or needs rebase; a hive agent is fixing it and removed stage/050-review-pending Review swarm requested; awaiting a verdict for the current head labels Oct 30, 2026
@hivecommons-hive

Copy link
Copy Markdown
Contributor Author

Correction to the note above: a job rerun isn't available from this agent, so instead I rebased the branch onto current v5 (e2d2a4c, where docker (contributor) is green) and pushed β€” content unchanged, CI retriggered. Proxy test api_internal_header.test.js passes locally on the rebased head.


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

β€” hive: agent=scanner backend=copilot model=claude-fable-5.1 copilot=1.0.88

@hivecommons-hive hivecommons-hive Bot added stage/050-review-pending Review swarm requested; awaiting a verdict for the current head and removed stage/070-fixing Hive-authored PR: CI red, changes requested or needs rebase; a hive agent is fixing it labels Oct 30, 2026

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 sibling PUBLIC_POST_PATHS at :1010 still uses startsWith, so /api/gh-user-auth/startx and /api/gh-user-auth/other keep 401ing, as the new tests assert. The Go API already treats /api/gh-user-auth/* (except /logout) as public at src/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 the hive_session cookie still has req.hiveTokenVerified === false, so the proxyReq hook at :1029-1032 removes X-Hive-Internal rather than injecting it. On the Go side the cookie is then resolved by sessionFromRequest + liveSessionRole at server.go:2150-2168; an unknown or revoked session leaves trusted=false and falls through to the 401 at the end of authenticate(). So forwarding an arbitrary cookie value (hive_session=abc123 in 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 issued SameSite=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.
  • parseCookies at server.js:518 returns 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

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_PATHS is matched with includes(req.url.split('?')[0]), so /api/gh-user-auth/startx and /api/gh-user-auth/other still fall to requireAuth (server.js:710 β†’ 401). The test file asserts both. The existing PUBLIC_POST_PATHS line above it uses startsWith; the new list deliberately does not.
  • server.js:1015 (new) β€” the hive_session branch only calls next(); it does not set req.hiveTokenVerified. X-Hive-Internal is injected solely on DASHBOARD_TOKEN && req.hiveTokenVerified (server.js:1029-1032), and the new test checks internal === null for the cookie case. So no owner-equivalent credential is minted for cookie traffic.
  • parseCookies exists at server.js:518 (shared with the terminal gates); the cookie name matches sessionCookieName = "hive_session" at pkg/dashboard/server.go:65.
  • Go side, pkg/dashboard/server.go:2149-2168 β€” sessionFromRequest + liveSessionRole resolve the cookie against the live allowlist on every request; a revoked/unknown/garbage session leaves trusted=false and the handler 401s at server.go:2233-2236. /api/gh-user-auth/* except /logout is already in Go's public allowlist (server.go:2418-2419), so start/poll were 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

@hivecommons-hive hivecommons-hive Bot added stage/085-needs-decision A human decision is owed: sentinel alert, hold/needs-decision label, human-only rule or parked issue and removed stage/050-review-pending Review swarm requested; awaiting a verdict for the current head labels Oct 30, 2026
@hivecommons-hive

Copy link
Copy Markdown
Contributor Author

Needs a decision, not a merge:

  • the reviewer swarm returned requires_human @e8e0ecb
  • the review found: the reviewer marked this change high-risk
  • reviewer question: @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().
  • the automerge lane will not merge this unattended

Head: verdict requires_human @e8e0ecb, 62/62 checks green, DCO yes, soak 0s of 10m0s.

What to do: approve this head (e8e0ecb) to merge as-is, or leave a changes requested review (or reply /hive decision <what to change>) and the hive will push the fix.

How to release it:

  • After reading the verdict, a trusted merger can submit a GitHub Approve review for the current head and the lane clears the hold on its next pass; /hive approve replies on a PR are acknowledged but not consumed.

Clear the cause and the hive re-evaluates on its next pass; the stage moves to stage/090-ready-for-human-merge, stage/095-pre-merge-soak or the merge queue on its own. Approval does not bypass CI, hold labels or other merge gates.

@clubanderson clubanderson left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@kubestellar-prow kubestellar-prow Bot added the lgtm Indicates that a PR is ready to be merged. label Oct 30, 2026
@kubestellar-prow

Copy link
Copy Markdown
Contributor

LGTM label has been added.

DetailsGit tree hash: 88ed7da54a0aa161843601dc52999e950962fb65

@hivecommons-hive hivecommons-hive Bot added stage/050-review-pending Review swarm requested; awaiting a verdict for the current head and removed stage/085-needs-decision A human decision is owed: sentinel alert, hold/needs-decision label, human-only rule or parked issue labels Oct 30, 2026
@hivecommons-hive hivecommons-hive Bot added stage/060-reviewed Review swarm verdict approve; a gate is still pending (CI running, soak not started) stage/070-fixing Hive-authored PR: CI red, changes requested or needs rebase; a hive agent is fixing it and removed stage/070-fixing Hive-authored PR: CI red, changes requested or needs rebase; a hive agent is fixing it stage/060-reviewed Review swarm verdict approve; a gate is still pending (CI running, soak not started) labels Oct 30, 2026
@hivecommons-hive

Copy link
Copy Markdown
Contributor Author

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: scanner | Instance: hosted-available-oke-11-placeholder-r05x | SHA: c30dc317e

β€” hive: agent=scanner backend=copilot model=claude-fable-5.1 copilot=1.0.88

@hivecommons-hive hivecommons-hive Bot added stage/050-review-pending Review swarm requested; awaiting a verdict for the current head and removed stage/070-fixing Hive-authored PR: CI red, changes requested or needs rebase; a hive agent is fixing it labels Oct 30, 2026

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed β€” no findings from this perspective.

β€” hive: agent=adjudicator-5 backend=copilot model=claude-fable-5.1 copilot=1.0.88

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed β€” no findings from this perspective.

β€” hive: agent=adjudicator-3 backend=copilot model=claude-fable-5.1 copilot=1.0.88

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed β€” no findings from this perspective.

β€” hive: agent=reviewer-2 backend=copilot model=claude-fable-5.1 copilot=1.0.88

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed β€” no findings from this perspective.

β€” hive: agent=adjudicator-4 backend=copilot model=claude-fable-5.1 copilot=1.0.88

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed β€” no findings from this perspective.

β€” hive: agent=reviewer backend=copilot model=claude-fable-5.1 copilot=1.0.88

@hivecommons-hive
hivecommons-hive Bot merged commit e0065e5 into v5 Oct 31, 2026
78 of 80 checks passed
@kubestellar-prow
kubestellar-prow Bot deleted the scanner/fix-15872 branch October 31, 2026 01:18
@hivecommons-hive

Copy link
Copy Markdown
Contributor Author
Evidence bundle `#15882c30dc31` sha256:109f07873001bef179d37fa82a4e9aff9951eefb5db3dc2952ac944e03f54c15 β€” download from the dashboard or `hivectl review evidence #15882`.

@github-actions

Copy link
Copy Markdown
Contributor

Thank you for your contribution! Your PR has been merged.

We'd love to hear how your experience was: share feedback

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

Labels

author/hive This repository's own hive (the App or one of its agent lanes) authored this PR copilot dco All commits are DCO signed-off dco-signoff: yes Indicates the PR's author has signed the DCO. role/trusted Author is trusted for unattended merge (trusted-author role or registry/claim tier in require_tiers) size/M Denotes a PR that changes 30-99 lines, ignoring generated files. stage/050-review-pending Review swarm requested; awaiting a verdict for the current head

Projects

None yet

Development

Successfully merging this pull request may close these issues.

πŸ› proxy: device-flow sign-in always 401s on direct-route spokes; hive_session mutations refused

1 participant