Repository navigation
π fix(proxy): task MCP and public knowledge MCP reach the hive through the gateway - #16905
Conversation
β¦h the gateway On Compose, Quadlet and LXC every request passes the Node auth proxy. Its gate answers 401 to a write with no dashboard token unless the path is on its public list, so the two MCP endpoints that authenticate their own callers never reached the Go API: the task MCP (launch token in ?token= or a lease bearer) and the public knowledge MCP (anonymous while the owner's switch is on). /mcp/knowledge had no route to the Go API either. Both paths join the exact-match public list (query string aside, never by prefix). /mcp/knowledge gets its own forwarder that drops X-Hive-Internal, X-Hive-User and X-Hive-Role; other methods on it answer 405, Allow: POST. X-Hive-Internal is still added only for a request that sent the dashboard token in its Authorization header. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Signed-off-by: Danathar <Danathar@users.noreply.github.com>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
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. |
There was a problem hiding this comment.
Decision needed: @clubanderson should decide whether the standalone gateway may forward anonymous POSTs on exactly /api/contribute/mcp and /mcp/knowledge to the Go API, relying on the Go-side launch-token/lease check and the owner's public-knowledge switch instead of the proxy's dashboard-token gate.
The code does what the body says, and I could not find a way for it to mint trust it should not. I'm routing it rather than calling it done because it widens the gateway's unauthenticated-write allowlist, which is a proxy-policy call for an approver (src/proxy/** is not in .github/CODEOWNERS; OWNERS approvers are the right people).
What I verified at ce1195e:
- The gate (
src/proxy/server.js:1038-1041) setshiveTokenVerifiedsolely frombearerTokenMatches(req.headers.authorization)(server.js:704-711), which never reads the query string, and the exact-path check usesreq.url.split('?')[0]. So a?token=<launch>request passes the gate withhiveTokenVerified=false, andapiProxythen strips rather than injectsX-Hive-Internal(server.js:1068-1071). A caller who does present the dashboard bearer getsX-Hive-Internalas before β unchanged behaviour for already-authenticated callers. - Go side:
isPublicPathalready allows/api/contribute/*(pkg/dashboard/server.go:2640) and/mcp/knowledgeonly whilepublicKnowledgeEnabled()(server.go:2603), so neither neededX-Hive-Internalto be reachable;handleContributeMCPauthenticates the lease, then the launch token, then falls back to a bearer check against the dashboard token (pkg/dashboard/task_mcp.go:36-41). Nothing on the Go side trusts the proxy for these two routes. knowledgeMcpProxy(server.js:1149-1166) stripsX-Hive-Internal,X-Hive-User,X-Hive-Roleunconditionally, and theapp.all405 atserver.js:1170-1173sits afterapp.post, so only POST is forwarded.- Exact matching means
/api/contribute/mcp/and/mcp/knowledge/extrastill hitrequireAuth; the new tests pin seven such siblings.
One thing the body flags itself, worth keeping in mind for the decision: PUT/PATCH/DELETE on /api/contribute/mcp also pass the gate (same as the existing device-flow paths) and rely on the Go mux to reject them. That's consistent with #15882 but it is the one place the allowlist is wider than "POST only".
Nothing here is a defect; the question above is the only thing I can't settle.
β hive: agent=reviewer-2 backend=copilot model=claude-fable-5.1 copilot=1.0.88
|
Needs a decision, not a merge:
Head: verdict requires_human @ce1195e, 63/63 checks green, DCO yes, soak 0s of 10m0s. How to release it:
Clear the cause and the hive re-evaluates on its next pass; the stage moves to |
There was a problem hiding this comment.
Decision needed: @clubanderson should confirm the dashboard auth proxy may forward anonymous POSTs to exactly /api/contribute/mcp and /mcp/knowledge, delegating caller authentication to the Go API for those two paths.
Read the code: the change does what it says, and it is a deliberate widening of the gateway's anonymous-write allowlist β flagging for a maintainer's sign-off rather than approving.
What I verified against this head (74bb1ad):
src/proxy/server.js:1038-1041β the gate setsreq.hiveTokenVerifiedfrombearerTokenMatches(req.headers.authorization)before the allowlist check, andbearerTokenMatches(server.js:704-712) reads only theAuthorizationheader. So a?token=launch token can never earnX-Hive-Internal;apiProxy(server.js:1068-1072) strips it unless the header matched. The "no credential leaks through" claim holds.src/pkg/dashboard/server.go:2644β/api/contribute/is already a Go public-path prefix, so the Go side was always reachable anonymously there;task_mcp.go:34-45then requires a lease bearer, a launch token, or the dashboard bearer and 401s otherwise. The proxy's 401 was purely redundant with a stricter check downstream. This is the real bug fix.src/pkg/dashboard/server.go:2603β/mcp/knowledgeis public in Go only whilepublicKnowledgeEnabled(); otherwise it falls through to normal auth. So the newknowledgeMcpProxy(server.js:1150-1172) opening it at the proxy does not open it at the hive while the owner's switch is off.- Exact-match semantics:
req.url.split('?')[0]against the list, so/mcp/knowledge/extra,/api/contribute/mcp/etc. still hitrequireAuth. The new sibling tests pin this. - Route order:
app.post('/mcp/knowledge')is registered after the token gate and beforeexpress.static(server.js:1304) and the SPA fallback (:1364), so the 405 handler correctly displaces the dashboard page for GET.
The PR body says the test could not be run against the real express/http-proxy-middleware. I ran node src/proxy/api_internal_header.test.js on this head with the real packages: 30/30 pass.
Body and diff agree; no mismatch found. Nothing else in the tree (docs, callers) needs to change β public-knowledge-mcp.md already defers reverse-proxy detail to the operator, and the changelog fragment is present.
The one thing I will not decide alone: this PR moves the authentication boundary for two write paths from the proxy to the Go API. Both Go handlers do fail closed today (cited above), but that now depends on task_mcp.go and publicKnowledgeEnabled() continuing to do so. That is a trust-surface change and belongs to an approver.
β hive: agent=reviewer-2 backend=copilot model=claude-fable-5.1 copilot=1.0.88
|
Hive status β updated in place; edits do not notify. Full history is in the Activity Monitor. Evidence bundle `#1690574bb1ad` sha256:a7b06204f0234f7f04fadd94af33cf9e4c547d26f204d97bfe0e550c77220ab0 β download from the dashboard or `hivectl review evidence #16905`.Review findings from HUMAN DECISION NEEDED β Security re-review at Previous finding β still present (unchanged, it is the change itself):
The mechanism is sound; the remaining question is policy (gateway no longer a second gate for these endpoints), which the hive won't decide for a contributor PR. Review findings from docs-currency (delta re-review Advisory (out of scope, pre-existing, already noted in your "Not in this change"): with Hive filed review findings that do not block this PR as backlog items:
Cap: 10 backlog item(s) per PR per day. |
Summary
On standalone deployments (Docker Compose, Podman Quadlet, LXC) every request goes through the bundled auth proxy before it reaches the hive. The proxy refused the hive's two MCP endpoints, although the hive checks their callers itself. Hub-launched agents and remote contributors got
401from the task MCP whenever its URL went through the gateway (dashboard.public_urlor a hub-assigned dashboard URL). The public knowledge MCP could not be reached at all, even with the owner's switch on. The proxy now forwards exactly these two paths and adds no credential of its own.What went wrong
The proxy answers a write request with
401unless it carries the dashboard token or a session cookie, or its path is on a short public list. Neither MCP path was on that list./mcp/knowledgealso had no route to the hive, so it failed even with the dashboard token.Before this change, with a dashboard token configured:
What changes
POST /api/contribute/mcppasses the proxy and reaches the hive. The hive verifies the launch token or the lease as before and refuses everyone else.POST /mcp/knowledgepasses the proxy and reaches the hive. The hive serves it only while the owner's "Public read-only MCP" switch is on./mcp/knowledgegets405withAllow: POSTinstead of the dashboard page./api/contribute/mcpx,/mcp/knowledge/extraand/mcp/otherstill get401.Why this is safe:
X-Hive-Internalonly when the request carried the dashboard token in itsAuthorizationheader. A token in the query string never counts, so a launch token cannot be taken for the dashboard token./mcp/knowledgethe proxy never addsX-Hive-Internal. It also removesX-Hive-Internal,X-Hive-UserandX-Hive-Roleif the client sent them.PUT,PATCHandDELETEon the two exact paths also pass the gate, as they already do for the device-flow sign-in paths. On/mcp/knowledgethe proxy answers them with405. On/api/contribute/mcpthe hive has no handler for them.This follows the device-flow sign-in change in #15882: same list, same exact match.
Not in this change: the endpoint URL shown under Settings β Knowledge is built from the request's
Hostheader, so behind the proxy it shows the internal address.Files
src/proxy/server.js: two paths added toPUBLIC_EXACT_POST_PATHS; newknowledgeMcpProxywith aPOSTroute and a405route for/mcp/knowledge.src/proxy/api_internal_header.test.js: the new checks; the mock hive echoesAuthorizationand thereqhelper returns response headers.changelog.d/fixed-proxy-mcp-endpoints.md: release note.Tests
New checks in
src/proxy/api_internal_header.test.js, which CI runs throughnpm test:?token=launch token is forwarded withoutX-Hive-Internal, query string intact.X-Hive-Internal,Authorizationintact.?token=never earnsX-Hive-Internal.POST /mcp/knowledgeis forwarded with no trust headers.X-Hive-Internal,X-Hive-UserandX-Hive-Roleon/mcp/knowledgenever reach the hive.POST /mcp/knowledgewith the dashboard token still gets noX-Hive-Internal.GET,PUTandDELETEon/mcp/knowledgeget405withAllow: POST.401:/api/contribute/mcpx,/api/contribute/mcp/,/api/contribute/mcp/extra,/mcp/knowledgex,/mcp/knowledge/,/mcp/knowledge/extra,/mcp/other.Without the change, every check above except the sibling ones fails (nine checks: they get
401or404instead). The seven sibling checks pass before and after. They pin the boundary.expressandhttp-proxy-middlewarewere not installed where this was prepared. The real test file was run against the realserver.jswith small local stand-ins for the two packages: 30 of 30 checks pass with the change, 21 of 30 without it. CI is the first run against the real packages.π€ Generated with Claude Code