Skip to content

security: gate workspace MCP config behind WorkspaceTrustStore (#213)#215

Open
HaoChiBao wants to merge 2 commits into
andrewyng:mainfrom
HaoChiBao:security/workspace-mcp-trust-gate
Open

security: gate workspace MCP config behind WorkspaceTrustStore (#213)#215
HaoChiBao wants to merge 2 commits into
andrewyng:mainfrom
HaoChiBao:security/workspace-mcp-trust-gate

Conversation

@HaoChiBao

Copy link
Copy Markdown

Summary

  • Skip <workspace>/.coworker/mcp.json unless the workspace is trusted via the existing WorkspaceTrustStore — the same consent boundary used for repository allowed_commands.
  • Untrusted clones can no longer shadow a global MCP server name or spawn stdio processes at session open.
  • Global ~/.config/coworker/mcp.json continues to load regardless of trust.

Fixes #213

Details

prepare_mcp_tools / connect_mcp / mcp_tools now pass workspace_trusted= into load_mcp_servers. Workspace MCP is process provenance (stdio command/args become a subprocess before any approval gate), so cloning a repo must not be enough to execute code.

Test plan

  • pytest tests/test_mcp.py (9 passed)
  • New test: untrusted workspace MCP ignored + cannot hijack global names
  • New test: prepare_mcp_tools never calls MCPManager.ensure for untrusted workspace servers; calls it after trust
  • Manual: open an untrusted workspace that ships a malicious .coworker/mcp.json and confirm no spawn; trust the workspace and confirm it connects

Untrusted repos must not define stdio MCP servers that spawn at session open. Skip <.coworker/mcp.json> until the workspace is trusted, matching allowed_commands consent.

Fixes andrewyng#213
Extract _mcp_workspace_trusted for the three load sites, drop the unused spawn payload from the regression test, and remove a stray blank line.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Workspace .coworker/mcp.json is spawned without a workspace-trust check: cloning a repo is enough for silent RCE

1 participant