Skip to content

Auto-discovery: skip project configs that read environment variables - #383

Draft
jancurn wants to merge 2 commits into
mainfrom
claude/security-review-2026-09-cdbsex
Draft

Auto-discovery: skip project configs that read environment variables#383
jancurn wants to merge 2 commits into
mainfrom
claude/security-review-2026-09-cdbsex

Conversation

@jancurn

@jancurn jancurn commented Sep 2, 2026

Copy link
Copy Markdown
Member

A bare mcpc connect read config files from the current directory and expanded any ${VAR} they referenced into headers, URLs, commands and env. A repo shipping .mcp.json with "headers": {"X": "${GITHUB_TOKEN}"} pointed at an attacker's server leaked the secret on the first request. Auto-discovery now treats project-scope files as untrusted; connecting a file by name (mcpc connect ./.mcp.json) stays the explicit trust step.

  • Project-scope entries that reference ${VAR} are skipped, shown as ○ skipped (reads ${VAR}) and as skipReason: "project-env" with envVars in --json; the listing names the headers each entry would send
  • -H is refused for auto-discovery (it would go to every discovered server)
  • Files under ~ still expand ${VAR}; running from the home directory keeps ~/.cursor/mcp.json and friends global-scoped
  • Help text, README, agent skill, CHANGELOG and the review doc updated; unit and e2e tests added

Fixes H3 in docs/security-review-2026-09.md (added in #381).

🤖 Generated with Claude Code

https://claude.ai/code/session_015KgWYoCqq84kS66AkoJsYR

…iables

A bare `mcpc connect` reads config files from the current directory —
files that may have been committed by someone else — and expanded any
`${VAR}` they referenced into headers, URLs, commands and env. A repo
shipping `.mcp.json` with `"headers": {"X": "${GITHUB_TOKEN}"}` (or a
`${SECRET}` in the hostname) pointed at an attacker's server exfiltrated
the secret on the first request, and `-H` given to auto-discovery was
fanned out to every discovered server.

Auto-discovery now treats project-scope files as untrusted: entries that
reference any `${VAR}` are skipped (shown as `○ skipped (reads ${VAR})`,
`skipReason: "project-env"` with `envVars` in --json), the listing names
the headers each entry would send, and `-H` is refused. Files under the
home directory are the user's own and still expand `${VAR}`, as does
naming a file explicitly (`mcpc connect ./.mcp.json`), which is the
deliberate trust step. Running from the home directory keeps user-level
locations such as `~/.cursor/mcp.json` global-scoped.

Refs docs/security-review-2026-09.md (H3).

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015KgWYoCqq84kS66AkoJsYR
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.

3 participants