fix(mcp): block exfil-shaped stdio server configs (#46083)
This commit is contained in:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user