Repository navigation
π dashboard: a hosted spoke's JSON 502 reaches the owner instead of the ingress page - #18601
Conversation
β¦he ingress page The hosted ingress intercepts 502/503 and serves its generic 'hive unavailable' page, so a 502 the spoke answered with its own error read as an outage. On a request carrying the hub's X-Hive-Proxy-Auth proof, a JSON 502 from an /api/ handler now goes out as 424 (passed through by the ingress) with X-Hive-Status: 502. Unreachable spokes still get the generic page; 503 is unchanged because the UI reads spoke 503s by status. Refs #18598 Signed-off-by: Andy Anderson <andy@clubanderson.com>
Open PR overlap checkβ
Resolved: no conflicting open PRs or same-file overlaps remain against |
There was a problem hiding this comment.
Security perspective, head 639b145: one in-scope trust-boundary finding (inline).
The X-Hive-Proxy-Auth proof is only tested for presence (hosted_gateway_status.go:40), but the wrapper sits outside authenticate, which does the real secureCompare against s.authToken (server.go:2170-2172). The comment says this "grants nothing", but it does change what an unauthenticated caller can read. isPublicPath leaves /api/contribute, /api/gh-user-auth/*, /api/v1, /api/leaderboard and others open (server.go:2545+). Today a 502 from those handlers, which can carry internal upstream error text, is replaced by the ingress's generic page. Any anonymous client who adds X-Hive-Proxy-Auth: x gets the 424 and the full body instead.
Fix: validate the proof the same way authenticate does.
β hive: agent=adjudicator-4 backend=claude model=claude-sonnet-5-5 claude=2.1.325
| // to an API route. The proof header's presence is enough here: this only | ||
| // picks the status an error is sent under, it grants nothing. | ||
| func isHostedGatewayRequest(r *http.Request) bool { | ||
| return r.Header.Get(proxyAuthHeader) != "" && strings.HasPrefix(r.URL.Path, "/api/") |
There was a problem hiding this comment.
Presence-only check lets any anonymous caller send a junk X-Hive-Proxy-Auth and unmask 502 bodies on public /api/ routes (contribute, gh-user-auth, v1...), which the ingress used to hide. Validate the proof like authenticate does (server.go:2170):
| return r.Header.Get(proxyAuthHeader) != "" && strings.HasPrefix(r.URL.Path, "/api/") | |
| func (s *Server) isHostedGatewayRequest(r *http.Request) bool { | |
| proof := r.Header.Get(proxyAuthHeader) | |
| return proof != "" && s.authToken != "" && secureCompare(proof, s.authToken) && strings.HasPrefix(r.URL.Path, "/api/") | |
| } |
and call s.isHostedGatewayRequest(r) at line 46. The test must then set the proof to the server's auth token.
|
[APPROVALNOTIFIER] This PR is APPROVED Approval requirements bypassed by manually added approval. This pull-request has been approved by: 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 |
|
Hive status β updated in place; edits do not notify. Full history is in the Activity Monitor. Review findings from Correctness review at head 639b145 (diff plus The rewrite mechanism is sound. 1. In-scope (medium): the 502β424 rewrite breaks client retry of transient spoke 502s.
2. In-scope (low): the wiring test does not prove the rewrite happens in the served chain.
3. Out-of-scope (info): the issue's logging half is not in this PR.
|
Fixes #18598 (the masking half; the meetings logging half is #18600).
Problem
The hosted ingress sets `custom-http-errors: "502,503"` and serves the error-pages backend for those codes. It cannot see the upstream body, so a 502 the spoke answered (e.g. `quorum meeting.join: blocked: the bot has no permission to connect to that voice channel`) became `{"ok":false,"error":"hive unavailable","detail":"This hive is restarting..."}`. The ingress access log showed the spoke answering in tens of milliseconds before the error-pages backend replaced it. #17037 hit the same thing and was fixed per handler; there are ~95 `StatusBadGateway` sites in `pkg/dashboard`.
Change
`withHostedGatewayPassthrough` (new `hosted_gateway_status.go`), wired into both dashboard handler chains outside `authenticate`:
Note: `inbox-recorder.js` retries on 502; a spoke-answered 502 on a hosted hive now arrives as 424 and is not retried. The spoke did answer, so that matches what the failure is.
Tests
`hosted_gateway_status_test.go`: a hosted JSON 502 becomes 424 with the body and header kept; self-hosted, non-API, non-JSON, 503, 409 and implicit 200 are unchanged; the served `Handler()` chain never lets a hosted JSON 502 through; writer pass-throughs.
π€ Generated with Claude Code