Repository navigation
fix(mcp): apply every access rule on the per-connection routes - #7453
Merged
Merged
Conversation
Den serves one connection on its own at two routes: /mcp/agent/connections/:id (the App host, and clients of a directly exposed connection) and /mcp/agent/servers/:id. Both check the member's grant on every request, but neither applied two rules that execute_capability applies to a granted connection. A connection whose OAuth issuer changed is blocked until an organization admin reviews it. The connections route did not look at that, so a client that already had the connection's URL kept calling the provider with the saved sign-in. A connection an admin set to "Not allowed" for Workbot is named in a Workbot turn's token. Only /mcp/agent read that from the token, so both per-connection routes served such a connection to a Workbot turn's token. Workbot's runner does not use these routes itself. The member is now built from the token in one place (mcpMemberForToken), and the two refusals come from one function (externalMcpConnectionHold) that execute_capability and the connections route both read. execute_capability keeps the order it had. The servers route treats a withheld connection as unavailable; its tool calls already run through execute_capability. Only a member with a grant is told why a connection is held. The connections route also threw on a malformed connection id, which surfaced as an unhandled server error. It now answers as it does for an unknown id. The connections route's lookups can be supplied by a caller, as the servers route's already can, so the new test drives both routes with a held connection and a Workbot token. The malformed id goes through the real app. The test is added to the security list so it runs on every PR. Signed-off-by: Jalil <reachjalil@gmail.com>
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub. 3 Skipped Deployments
|
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What is this about?
The two Den routes that serve a single connection as its own MCP server. They now apply the same access rules as the main agent endpoint.
What problem does it solve?
Two rules an admin relies on were skipped there: a connection blocked until its changed sign-in provider is reviewed, and a connection set to "Not allowed" for Workbot. A malformed connection id also caused a server error instead of a refusal.
What was the situation before?
A client that already had a connection's URL kept getting answers from a connection every other path reported as blocked for review. A Workbot turn's token was served a connection the admin had taken away from Workbot. A request with a malformed id got a 500.
How is this implemented?
external-capabilities.ts:mcpMemberForTokenbuilds the member from the token, including the connections withheld from Workbot;externalMcpConnectionHoldreturns the review or Workbot refusal.execute_capabilityreads both from it, in the order it had.external-connection-proxy.ts(/mcp/agent/connections/:id): applies the hold after the grant check, so only a member with access is told why. A malformed id gets the same 403 as an unknown one.connection-server.ts(/mcp/agent/servers/:id): builds its member the same way and treats a withheld connection as unavailable.What else changed?
test:api:securitylist.Release note
Connections blocked for an admin's review, or not allowed for Workbot, are now refused on every route that reaches them.
Evidence
ee/apps/den-api/test/api/mcp-connection-route-access.api.test.ts— before: a blocked or Workbot-withheld connection is served and a malformed id returns 500; after: each is refused. No E2E; no screen changed.