fix(mcp): block suspicious stdio configs before probe - #46112
Merged
Conversation
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
MCP stdio configs now reject exfil-shaped commands before any probe/connect path can spawn them.
PR #46083 blocked persistence and config-loaded runtime startup, but
hermes mcp addstill probed a suspicious stdio command before the save-time rejection. This follow-up moves the guard ahead of probe/connect and reuses it for explicit runtime registration paths such as ACP-provided MCP servers.Changes
hermes_cli/mcp_config.py: validate suspicious stdio entries beforecmd_mcp_addprobe and inside_probe_single_serverbefore_connect_server.tools/mcp_tool.py: centralize suspicious MCP filtering and apply it to both config-loaded discovery and directregister_mcp_servers()calls.hermes_cli/config.py: avoid the temporary validator name assignment pattern that produced type-checker warnings.tests/hermes_cli/test_mcp_security.py: add regressions proving dangerous entries do not reach probe, connect, or explicit runtime registration.Validation
python3 -m py_compile hermes_cli/mcp_config.py tools/mcp_tool.py hermes_cli/config.py tests/hermes_cli/test_mcp_security.pyscripts/run_tests.sh tests/hermes_cli/test_mcp_security.py tests/hermes_cli/test_mcp_config.py tests/hermes_cli/test_mcp_catalog.py tests/tools/test_mcp_tool.pyInfographic