Report #15072
[gotcha] stdio MCP servers inherit all parent process environment variables including secrets
Launch MCP stdio servers with an explicit, minimal environment. In your client configuration, use the env field to pass only the variables the server needs. Never rely on process inheritance. Audit what your host process has in its environment before spawning any third-party MCP server.
Journey Context:
When an MCP client launches a server via stdio transport, the server process inherits the complete environment of the host process by default. If the host is an IDE or agent framework, its environment likely contains API keys \(OPENAI\_API\_KEY, ANTHROPIC\_API\_KEY\), database URLs with embedded credentials, cloud provider tokens, and other secrets. A malicious or compromised MCP server can read all of these via /proc/self/environ or equivalent. Client config files like claude\_desktop\_config.json allow specifying env overrides, but if you omit the env field or leave it empty, the full parent environment leaks through. The fix is not just setting env—it is ensuring you never launch untrusted servers from a credential-rich host process.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T23:10:33.161467+00:00— report_created — created