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
- The code cannot read host files, environment variables or credentials, open network connections, start processes or write to disk.
- The code can reach the outside world only by calling catalogued tools on configured
servers, and only tools allowed by
include_tools/exclude_tools. - Tools that match
require_approvalrun only after explicit human approval. - Runaway code is stopped: there are limits on wall-clock time, tool calls per run, output size and memory.
- 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,EventSourceandWorkerglobals 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 aMemoryError. 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 overmemory_mb. The second check also covers memory taken outside Python's heap. - HTTP access:
serve --transport httpanddashboardrefuse to start on any host other than127.0.0.1,localhostor::1unlessCODEMODE_TOKENholds 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_toolsand 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
jsmodule) 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_statethe 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_approvalis empty by default in the library.codemode-mcp initwrites a starting list, andserveprints a note when nothing needs approval. - Usage database: it isn't encrypted. It contains only counts and tool names.