Skip to content

fix(security): block STDIO command injection — RCE at connection creation - #4023

Merged
guitavano merged 1 commit into
mainfrom
fix/stdio-rce-command-injection
Jun 19, 2026
Merged

guitavano merged 1 commit into
mainfrom
fix/stdio-rce-command-injection

Conversation

@0xcucumbersalad

@0xcucumbersalad 0xcucumbersalad commented Jun 19, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Critical: OS command injection via STDIO MCP connections. Any authenticated user could execute arbitrary commands on the server by creating a STDIO connection with a malicious command/args in connection_headers.

The proxy-time path (outbound/index.ts:54-60) correctly blocks STDIO spawns outside local mode. But the creation-time path (create.ts → fetchToolsFromMCP() → fetchToolsFromStdioMCP() → new StdioClientTransport({command, args})) had no localMode guard — user-supplied commands were spawned immediately as child processes, with errors silenced by .catch(() => null).

Attack vector

POST /api/:org/tools/COLLECTION_CONNECTIONS_CREATE
{
  "data": {
    "connection_type": "STDIO",
    "connection_headers": {
      "command": "bash",
      "args": ["-c", "id > /tmp/rce_proof.txt"]
    }
  }
}
# → 200 OK, command already executed on server

Fix — three guards added

File Guard
apps/mesh/src/tools/connection/create.ts Reject STDIO connection_type when not in local mode (primary)
apps/mesh/src/tools/connection/update.ts Same guard on the update path
apps/mesh/src/tools/connection/fetch-tools.ts Defense-in-depth localMode check inside fetchToolsFromStdioMCP before any StdioClientTransport spawn

Test plan

  • bun run check — passes
  • bun run fmt — passes
  • bun run lint — passes (0 errors)
  • Verify STDIO connection creation returns error when localMode=false
  • Verify STDIO connection creation still works in local mode (--local-mode)
  • Verify STDIO connection update returns error when localMode=false

🤖 Generated with Claude Code


Summary by cubic

Fixes a critical RCE by blocking STDIO MCP connection create/update outside local mode and adding a defense-in-depth check in the fetch path. Prevents arbitrary command execution on the server; STDIO now works only in local mode.

  • Bug Fixes

    • Reject STDIO connection create/update when localMode is false.
    • Add localMode guard in fetchToolsFromStdioMCP to prevent any spawn in non-local environments.
  • Migration

    • Production: STDIO connections are disabled. To use STDIO, run the server with --local-mode.
    • No changes for SSE or HTTP connections.

Written for commit d921220. Summary will update on new commits.

Review in cubic

STDIO MCP connections spawn arbitrary commands as child processes via
StdioClientTransport. The proxy-time path (outbound/index.ts) had a
localMode guard, but the creation-time path (create.ts → fetch-tools.ts
→ StdioClientTransport) did not — allowing any authenticated user to
execute arbitrary OS commands on the server by creating a STDIO
connection with a malicious command/args in connection_headers.

Three guards added:
1. create.ts: reject STDIO connection_type when not in local mode
2. update.ts: reject STDIO connection_type when not in local mode
3. fetch-tools.ts: defense-in-depth localMode check in
   fetchToolsFromStdioMCP before spawning

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
@guitavano
guitavano merged commit 2095bdd into main Jun 19, 2026
14 checks passed
@guitavano
guitavano deleted the fix/stdio-rce-command-injection branch June 19, 2026 12:55
decocms Bot pushed a commit that referenced this pull request Jun 19, 2026
PR: #4023 fix(security): block STDIO command injection — RCE at connection creation
Bump type: patch

- decocms (apps/mesh/package.json): 3.36.0 -> 3.36.1

Deploy-Scope: server
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants