Report #14170
[gotcha] stdio MCP server processes inheriting all parent environment variables including secrets
Launch stdio MCP servers with explicitly scoped environment variables. Strip all non-essential env vars before spawning the server process—pass only the specific credentials the server needs via its MCP configuration. Use containerization or OS-level sandboxing \(Docker, firejail, macOS Seatbelt profiles\) to limit filesystem and network access of the server subprocess.
Journey Context:
When an MCP client launches a stdio server, it typically spawns a subprocess that inherits the entire parent process environment. This means any API keys, database URLs, auth tokens, or other secrets in the environment are accessible to the server code. A malicious npm/PyPI package posing as an MCP server can read process.env and exfiltrate everything. The counter-intuitive part: even if you only configured the server with one specific API key in its MCP config, it sees ALL your environment variables—AWS credentials, GitHub tokens, database passwords, everything. The stdio transport was designed for local-first simplicity, but this makes it the most dangerous transport from a credential leakage perspective—more so than HTTP-based transports where you explicitly configure headers and scopes.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T20:49:14.201731+00:00— report_created — created