fix(mcp): reject config-supplied stdio MCP servers by default - #6547
fix(mcp): reject config-supplied stdio MCP servers by default#6547yusmer96-maker wants to merge 9 commits into
Conversation
McpToolset.from_config() passed stdio_server_params.command and args straight from the agent config to the MCP stdio transport, which launches them as a local process. Agent configs are untrusted input, so this made a YAML config a process-execution primitive. Reject stdio connection params in from_config() unless the embedding application opts in via _set_allow_config_stdio_servers(True). Remote transports (SSE, streamable HTTP) are unaffected.
Add tests for from_config() rejecting stdio_server_params and stdio_connection_params by default, allowing them under the _set_allow_config_stdio_servers(True) opt-in, and leaving remote transports (SSE) unaffected. Update the existing credential_key test to opt in for its stdio config.
|
any updates? |
|
?? |
|
Hi @wukath, The commit landed on Aug 10 ( This repo normally preserves external contributors as co-authors through the export pipeline — the elicitation_callback, header-provider and sampling-callback commits on this same file all do it. Could a Happy to close this PR once that's recorded. |
Link to Issue or Description of Change
2. Or, if no issue exists, describe the change:
Problem:
McpToolset.from_config()acceptsstdio_server_params/stdio_connection_paramsdirectly from an agent config. Those carry acommandand
argsthat the MCP stdio transport launches as a local process, so loadingan agent config can start an arbitrary process on the first agent turn — before
the model is contacted.
Agent configs are not necessarily authored by the person running the agent: they
are shared as bundles, templates, samples and registry entries. That makes
config loading equivalent to code execution for anyone who runs an agent they
did not write.
ADK already treats this input as untrusted elsewhere: the
argskey is blockedfor Agent Builder uploads (
fast_api.py) and for disk loads when the web UI isenabled (
config_agent_utils._set_enforce_yaml_key_denylist). It was simply notenforced on the default
adk run/adk api_serverpaths.Solution:
from_config()now rejects stdio connection params unless the embeddingapplication explicitly opts in via
_set_allow_config_stdio_servers(True).Applications that legitimately launch local MCP servers from config keep working
by opting in; everything else fails closed.
Unaffected: remote transports (
sse_connection_params,streamable_http_connection_params), constructingMcpToolsetdirectly incode, and applications that opt in.
Testing Plan
Unit Tests:
pytest tests/unittests/tools/mcp_tool/test_mcp_toolset.py -k from_configtest_from_config_with_credential_key(updated to opt in)test_from_config_rejects_stdio_server_paramstest_from_config_rejects_stdio_connection_paramstest_from_config_allows_stdio_when_opted_intest_from_config_allows_remote_connection_paramsManual End-to-End (E2E) Tests:
Two agent bundles, each a single
root_agent.yaml, run withadk run.1 — stdio MCP server declared in an agent config (now rejected):
adk runnow fails at config load with the newValueError. Before thischange the same config launched the configured command on the first turn.
2 — remote MCP server in an agent config (unchanged):
The toolset builds normally and the run proceeds to the model step, confirming
remote transports are not affected.
Additional context
Reported through the Google VRP (issue 541474207); this PR is the corresponding
fix. Related hardening on the same surface in the Go SDK: google/adk-go#923.