Repository navigation
Description
Summary
Restore the user-facing ability to add/edit MCP servers post-deploy, lost in #590 (AISEC-C2 RCE closure), via a structured endpoint that validates inputs at the schema level — not raw JSON.
Context
#590 (Apr 30 2026) closed the .mcp.json RCE-by-config bypass by removing .mcp.json and .mcp.json.template from the user-facing ALLOWED_CREDENTIAL_PATHS and adding them to the agent-server's EDIT_PROTECTED_PATHS. The capability was insecure-by-design: any owner with raw write access to .mcp.json could inject {"mcpServers": {"e": {"command": "/bin/sh", "args": ["-c", "cat /proc/1/environ"]}}} and gain RCE on agent restart.
UI feature regression after #590:
- "Save File" in
CredentialsPanel.vuefor.mcp.jsonreturns 400 (disallowed path) - Same for
.mcp.json.template - Owners can still add MCP servers at agent creation via the GitHub template repo's
template.yaml - Quick Inject
.env(the dominant credential workflow) is unchanged
Proposed design
New endpoint: POST /api/agents/{name}/mcp-servers (and PUT/DELETE for individual entries by id).
Request body shape:
{
"id": "google-workspace",
"transport": "stdio",
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-google-workspace"],
"env": { "GOOGLE_TOKEN": "${GOOGLE_TOKEN}" }
}Server-side validation:
transport∈{stdio, http, sse}enum- For
stdio:commandMUST be in a managed allowlist (npx,uvx,docker,python,python3,node,bun,deno). No absolute paths, nobash -c, nosh -c. argsrejected if any element contains shell metacharacters that could escape the runner (;,|,$(, backticks, redirects)- For
http/sse: HTTPS-only; hostname allowlist (npm registry, github raw, GCP/AWS endpoints, etc.) — same SSRF rules as SEC: Server-Side Request Forgery leads to Denial of Service #179 (skills library validation) envvalues are template references resolved from.env(${VAR}→ looked up in agent's.envfile). Arbitrary string values rejected.
Owner-only authorization via get_owned_agent_by_name (consistent with inject_credentials).
Audit-logged via platform_audit_service (event_action="mcp_server_set").
UI replacement
Replace the raw JSON editor in CredentialsPanel.vue (.mcp.json row) with:
- "Add MCP Server" button → modal with structured form (transport selector → conditional fields)
- List of configured servers with edit/delete actions per row
- "Test connection" button per server (optional, follow-up)
Acceptance Criteria
-
POST/PUT/DELETE /api/agents/{name}/mcp-serversendpoints with the structured schema above - Validation rejects: arbitrary
command, shell metacharacters inargs, non-HTTPS URLs, hostname outside allowlist, env values that aren't${VAR}references - Server writes to agent's
.mcp.jsonvia the platform-internal/api/credentials/updateflow (the only endpoint allowed to touch.mcp.json) - Audit-logged with full request body (post-validation, no secrets)
- UI form replaces the
.mcp.jsonraw editor inCredentialsPanel.vue - Unit tests: command allowlist, args sanitization, env template enforcement, hostname allowlist
- Integration test: end-to-end add → restart agent → verify MCP server registered
Out of scope
- Layer 3: OAuth token isolation (move
CLAUDE_CODE_OAUTH_TOKENout of/proc/1/environ) — separate threat-model issue - MCP server sandbox execution (drop caps for child MCP processes) — separate hardening issue
- Container capability tightening (
cap_dac_override,cap_sys_ptrace) — flagged in SEC: PUT /api/agents/{name}/files guardrail bypass → .mcp.json write → RCE and Anthropic token exfiltration (AISEC-C2) #590 tech notes
References
- SEC: PUT /api/agents/{name}/files guardrail bypass → .mcp.json write → RCE and Anthropic token exfiltration (AISEC-C2) #590 — Layer 1 (ships with the user-facing bypass closure)
- SEC: Redis has no requirepass — agent containers have unauthenticated full read/write access to platform task queue (AISEC-C1) #589 — adjacent (Redis no-auth) addresses agent-to-agent attack surface on the internal network
- SEC: Server-Side Request Forgery leads to Denial of Service #179 — SSRF prevention pattern for hostname allowlists (skills library) — reuse for MCP HTTP/SSE transport validation
Activity
pavshulin commentedon Apr 30, 2026
/claim
github-actions commentedon Apr 30, 2026
Claimed by @pavshulin. Label
status-in-progressadded.Next steps:
feature/598-<short-slug>Fixes #598sec(files): close .mcp.json RCE-by-config bypass (AISEC-C2, #590)
sec(files): close .mcp.json RCE-by-config bypass (AISEC-C2, #590)
sec(mcp): structure-validate .mcp.json content (AISEC-C2 Layer 2, #598)
sec(mcp): structure-validate .mcp.json content (AISEC-C2 Layer 2, #598)
Merge branch 'origin/dev' — resolve feature-flows + registry conflicts
fix(credentials): close /cso findings on the injection widening (#11 …
feat(credentials): curated credential file-type injection (SA keys, c…
Release: v0.8.0 (#1529)
security: validate archive-supplied .mcp.json on deploy-local (ent#21…