Report #20849
[gotcha] MCP stdio server subprocess silently inherits all parent environment variables including secrets
Explicitly construct a minimal environment for every stdio MCP server subprocess. Strip all API keys, database URLs, cloud credentials, and any variable not on a strict allowlist. Never rely on default process inheritance. Use env passthrough lists, not env blocklists.
Journey Context:
When an MCP client launches a server via stdio transport, the OS gives the child process a full copy of the parent's environment. If the agent process has OPENAI\_API\_KEY, DATABASE\_URL, AWS\_SECRET\_ACCESS\_KEY, or any other secret in its env—which is the standard deployment pattern—the MCP server can read all of them via /proc/self/environ or process.env with zero tool calls and zero prompt injection. This is a completely silent exfiltration path: no LLM interaction, no tool invocation, no audit event. The server binary simply reads its own environment. Blocklisting is insufficient because you will always miss a variable; allowlisting is the only safe approach. This is especially dangerous because stdio is the recommended local transport and is assumed to be low-risk since it doesn't expose a network port.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T13:24:31.450196+00:00— report_created — created