Repository navigation
fix(mcp): gate chat ACL on admin role, not username "admin" - #4658
Conversation
…4654) /api/mcp/validate now returns user_role alongside the existing fields. McpAuthContext gains a userRole field populated at auth time. checkAgentAccess in chat.ts uses authContext.userRole === "admin" instead of the previous username string comparison, so a renamed admin retains access and an account named "admin" without the role is refused. Regression test: chat.admin-acl.test.ts (2 cases). Closes #4654 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
… assertion (#4654) The validate response's user_role and the server's hand-off into the auth context were unpinned: deleting either left every test green while every admin lost the bypass. Also notes on the type that userRole is the owner's role on every scope, and documents the field. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
39433f7 to
bf69e89
Compare
|
merge-train (2026-11-19): validated at
Also in that commit: the denial assertion in |
Summary
chat.ts:checkAgentAccesspreviously bypassed ACL withcallerOwner === "admin" || authContext.userId === "admin"— a string comparison against the literal username, not a role check"admin"gained it regardless of role/api/mcp/validatenow returnsuser_rolefrom theuserstable;McpAuthContextgets auserRolefield; the bypass is nowauthContext.userRole === "admin"Files changed
src/backend/db/mcp_keys.pyusers.c.roleto the validation query, return asuser_rolesrc/backend/routers/mcp_keys.pyuser_rolethrough the HTTP responsesrc/mcp-server/src/types.tsuserRole?: stringtoMcpAuthContextsrc/mcp-server/src/server.tsuserRolefrom validation resultsrc/mcp-server/src/tools/chat.tsuserRole === "admin"for the bypasssrc/mcp-server/src/tools/chat.admin-acl.test.tsTest plan
chat.admin-acl.test.ts— username"admin"with role"user"is denied; username"superadmin"with role"admin"is allowed (150/150 chat+access tests pass)Closes #4654
🤖 Generated with Claude Code