You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
bug(mcp): user-scope access gate recognises admins by the literal username admin, not by role — a second admin's user key is denied chat_with_agent/fan_out on agents it does not own #2824
src/mcp-server/src/tools/chat.ts::checkAgentAccess (the user-scoped branch, also reached by fan_out and the dedicated chat_with_<slug> tools) grants the admin bypass with a literal-username test:
McpAuthContext carries userId (the username) but no role, so a user promoted to role=admin under any other username (PUT /api/users/{id}/role exists for exactly that) is denied chat_with_agent / fan_out on agents they neither own nor are shared — while the backend's own rule (db.can_user_access_agent: owner, shared-with-user, or role == "admin") would allow the same call over REST. A false denial (fail-closed), not a bypass.
Context
Found by an independent reviewer during the abilityai/trinity-enterprise#628 plan review. Verified in code. The reviewer's companion claim — that the branch's is_shared test reads a global flag — was checked and is not a defect: GET /api/agents/{name} computes is_shared per requesting user (services/agent_service/helpers.py, is_shared_with_user). Only the admin test is wrong.
Five of the six other MCP gate copies (git.ts, executions.ts, reports.ts, operator_queue.ts, a2a.ts) pass user scope through and let the backend decide; chat.ts is the one that re-implements the user rule at the MCP layer.
Acceptance Criteria
A role=admin user whose username is not admin can chat_with_agent / fan_out any agent through a user-scoped MCP key, matching what the REST route already allows
Either McpAuthContext carries role from key validation and the branch tests it, or the MCP user branch defers to the backend the way the other gate copies do — decided and stated in the PR
A unit test in src/mcp-server/src/chat.test.ts (or the shared gate's test) pins a non-admin-named admin as allowed and a plain user on a foreign, unshared agent as denied with the uniform not found or not accessible reason (SEC: User and Agent Enumeration via differential API responses #186)
Technical Notes
The uniform-denial and no-owner-disclosure properties of the branch (#186) must survive the fix. After abilityai/trinity-enterprise#628 the agent-scope half of this function lives in src/mcp-server/src/access.ts; the user branch stays in chat.ts, which is where this change lands.
Activity