fix(mcp): block exfil-shaped stdio server configs (#46083)

This commit is contained in:
Teknium
2026-06-14 04:24:14 -07:00
committed by GitHub
parent 9459057d7f
commit 972a9885ee
10 changed files with 422 additions and 18 deletions
+10 -1
View File
@@ -7134,7 +7134,11 @@ async def add_mcp_server(body: MCPServerCreate, profile: Optional[str] = None):
try:
with _profile_scope(body.profile or profile):
_save_mcp_server(name, server_config)
if not _save_mcp_server(name, server_config):
raise HTTPException(
status_code=400,
detail=f"Server '{name}' rejected: suspicious command/args configuration",
)
except HTTPException:
raise
except Exception as exc:
@@ -8732,6 +8736,7 @@ def _write_profile_mcp_servers(profile_dir: Path, servers: List["MCPServerCreate
Returns the number of servers written.
"""
from hermes_constants import set_hermes_home_override, reset_hermes_home_override
from hermes_cli.mcp_security import validate_mcp_server_entry
written = 0
token = set_hermes_home_override(str(profile_dir))
@@ -8757,6 +8762,10 @@ def _write_profile_mcp_servers(profile_dir: Path, servers: List["MCPServerCreate
# Nothing usable to write (neither url nor command) — skip
# rather than persist an empty, unusable server stanza.
continue
issues = validate_mcp_server_entry(name, entry)
if issues:
_log.warning("Profile-create: skipping MCP server '%s': %s", name, "; ".join(issues))
continue
mcp[name] = entry
written += 1
if written: