Skip to content

Security policy

Reporting a vulnerability

Please report security issues privately, using GitHub's Report a vulnerability button (Security tab), not in public issues. We aim to reply within 3 business days.

Threat model

codemode-mcp runs code written by an LLM. We assume the code may be malicious, for example because the model was prompt-injected by data returned from a tool.

Goals

  1. The code cannot read host files, environment variables or credentials, open network connections, start processes or write to disk.
  2. The code can reach the outside world only by calling catalogued tools on configured servers, and only tools allowed by include_tools / exclude_tools.
  3. Tools that match require_approval run only after explicit human approval.
  4. Runaway code is stopped: there are limits on wall-clock time, tool calls per run, output size and memory.
  5. The HTTP endpoint and dashboard cannot be reached from another machine without an access token.

Mechanisms

  • Python runs in Pyodide (WebAssembly) inside Deno with --deny-net --deny-env --deny-run --deny-write --deny-ffi --deny-sys --no-prompt, and read access only to Deno's npm cache.
  • The Deno, fetch, WebSocket, XMLHttpRequest, EventSource and Worker globals are removed before user code runs (defence in depth).
  • The host checks every tool request against the catalogue and allow lists before forwarding it. Forged messages from inside the sandbox can't call unknown tools.
  • Secrets (env vars for stdio servers, HTTP headers, OAuth tokens) live only in the host process.
  • Memory is limited twice. Inside the sandbox, Python's heap (WebAssembly memory) cannot grow past memory_mb; the script gets a MemoryError. From outside, the host reads the sandbox process's size twice a second and after every run, and replaces the process if it is more than 384 MB over memory_mb. The second check also covers memory taken outside Python's heap.
  • HTTP access: serve --transport http and dashboard refuse to start on any host other than 127.0.0.1, localhost or ::1 unless CODEMODE_TOKEN holds a token of at least 16 characters. With a token set, every request must carry it (Authorization: Bearer <token>; a browser may send it as the password of HTTP Basic auth). Comparison is constant-time.
  • Approvals are bound to their question. Each question gets a single-use token, so a repeated or late answer cannot approve a different call, and a retry the proxy cannot place never runs the script again. Calls a script starts at the same time are asked about one by one.

Out of scope / known limits

  • Intended tool use: a compromised model can still misuse the tools you give it. Use require_approval, exclude_tools and least-privilege credentials, as you would with plain MCP.
  • Upstream servers: they run with your privileges. Only configure servers you trust.
  • Memory outside Python's heap: the outside check runs twice a second, so a script that reaches past Python (through Pyodide's js module) can exceed the limit for up to half a second before the process is replaced. Where the host cannot read a process's size, only the in-sandbox limit applies. The outside check is tested on macOS and Linux; the Windows code path has not been run.
  • One token, one tenant: the HTTP token is a shared secret, not user accounts. Everyone who has it uses the same tools with your upstream credentials and the same sandbox process, and with persistent_state the same variables. For several users, run one instance each, or put an authenticating gateway in front. The token travels in a header, so use TLS (a reverse proxy) on any network you do not control.
  • Approvals are off unless configured: require_approval is empty by default in the library. codemode-mcp init writes a starting list, and serve prints a note when nothing needs approval.
  • Usage database: it isn't encrypted. It contains only counts and tool names.