Report #29938
[gotcha] MCP server processes inherit the full host environment, exposing credentials meant for other services
Use MCP server-specific environment variable scoping — pass only the minimum required variables to each server process. Avoid running MCP servers from environments that contain broad credential sets. Use dedicated secret management or per-server .env files. Audit what environment variables each MCP server process can actually access at runtime.
Journey Context:
The standard way to configure MCP servers is by passing environment variables in the server configuration \(e.g., the \`env\` field in the config\). However, the spawned server process typically inherits the entire parent process environment, not just the specified variables. In Node.js-based clients, child\_process.spawn inherits the parent environment by default and merges in the specified env options. This means the MCP server has access to all credentials in the host environment — cloud API keys, database passwords, other service tokens — not just the ones you explicitly configured for it. A malicious server can read process.env and exfiltrate everything through tool outputs or sampling requests. Developers assume they're only giving the server the specific variables they configured, but the process gets the full inheritance.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T04:38:25.617901+00:00— report_created — created