HTTP boundary passes websocket scopes to the inner app unguarded #41
Labels
No labels
epic
needs-info
needs-triage
ready-for-agent
ready-for-human
svd:fire
svd:go
svd:hold
svd:respec
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
dev/attention-mind-mcp#41
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
The HTTP
Boundaryinsrc/attention_mind_mcp/mcp_adapter.pypasses every non-httpASGI scope straight to the inner app (mcp_adapter.py:152-154at PR #40 head99bbcf65). That includeswebsocketscopes. The Host check, the Origin refusal and the bearer check from #39 apply only tohttpscopes.Today a websocket upgrade to
/mcp,/mcp/or/is refused with 403. A raw-socket probe of the served app showed this during the PR #40 security review. The refusal comes from a framework detail: fastmcp registers/mcpas a StarletteRoute, and aRoutematches onlyhttpscopes. A later fastmcp or Starlette version that adds a websocket route or aMountwould expose that route with no Host, Origin or bearer check.Requirement
The
Boundaryrefuses every scope type excepthttpandlifespan, before it calls the inner app.lifespanmust still pass through, because it starts the session manager.Acceptance criteria
websocketscope getswebsocket.closewith code 1008, and the inner app is never called.lifespanscope still reaches the inner app, and the served app starts./mcpon the real served app and sees a refusal, with and without a bearer, a foreign Host or an Origin header.Boundarywith a rawwebsocketscope and asserts that the inner app is not called.Notes
src/messages_mind_mcp/face.py:167-174does this.Human act
ruling: the operator moves #41 to ready-for-agent after #35 merges (CONV-40)
Blocked by
Filed under: operator-word-d982c2768589
Triage: ready-for-human (parked until #35 merges)
Category: enhancement (defence in depth; this repo has no category labels)
Summary: the HTTP
Boundarymust refuse every ASGI scope type excepthttpandlifespanbefore it calls the inner app.Current behaviour:
Boundarypasses every non-httpscope to the inner app. Awebsocketscope therefore skips the Host check, the Origin refusal and the bearer check from #39. Today no websocket route exists: the PR #40 security probe sent upgrades to/mcp,/mcp/and/on the served app, with and without a bearer, a foreign Host or an Origin header, and every one got 403. The refusal comes from the framework, because fastmcp's/mcproute matches onlyhttpscopes.Desired behaviour:
lifespanstill reaches the inner app. Every other non-httpscope getswebsocket.closewith code 1008 at theBoundary, and the inner app is never called.Key interfaces:
Boundary.__call__(scope, receive, send): the scope-type dispatch at its top.Face.__call__does the same and counts the refusal under aprotocolreason.Acceptance criteria:
Boundarywith a rawwebsocketscope and assertswebsocket.closecode 1008, with the inner app not called.lifespanscope still reaches the inner app./mcpon the real served app and sees a refusal with and without a bearer, a foreign Host and an Origin header.Out of scope: CORS,
X-Forwarded-Host, any change to the #39 Host and Origin rules, and.woodpecker/.Why ready-for-human now: the change is bounded and agent-shaped. It touches the network trust boundary (CONV-40 rule 3), and it closes no live gap. The operator ruled to land it after the #6 chain: every attention merge moves main and forces a rebaseline of any spec waiting for dispatch. When #35 merges, move this issue to
ready-for-agent.Evidence: the #39 spec scopes websocket handling out (its open risk 4 asks for a follow-up only if an upgrade is not refused). The PR #40 security review recorded the probe.