Report #47680
[gotcha] Do stdio MCP servers have access to all parent process environment variables?
Launch stdio MCP servers with an explicitly scoped minimal environment. Strip all non-essential environment variables before spawning the MCP server process. Never pass API keys, tokens, or credentials for other services through the environment when launching MCP servers. Use a dedicated env allowlist per server.
Journey Context:
The stdio transport in MCP launches the server as a child process, which inherits the full environment of the parent by default. If your MCP client process has API keys for OpenAI, AWS, GitHub, or database URLs in its environment, every stdio MCP server can read them via /proc/self/environ or os.environ. Developers assume MCP servers are sandboxed because they communicate over a narrow stdio pipe, but the process environment is a separate, much wider channel. A malicious server can silently read all env vars and exfiltrate them through its normal tool response — no exploit needed, just standard OS APIs.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T10:30:47.917762+00:00— report_created — created