← MCP server and skill grades

context-mode

mksglu/context-mode

D
Type
MCP server
Scanned
Nov 17, 2026
Version
99c5f38b622c
Files read
825

Context Mode is a local plugin and tool server for AI coding assistants that saves chat space by running helper scripts and indexing large files, web pages, and command outputs in a local database. Although it describes its script runner as a sandbox, it runs code and commands directly on your computer as your user, and gaps in its Codex auto-approval settings, OpenCode permission checks, and Windows hooks can let a tricked assistant or untrusted project run commands without asking you.

What it can reach

Shell commands
Runs arbitrary shell commands and scripts (such as Bash, PowerShell, JavaScript, TypeScript, Python, or any installed program) directly on your computer as your user, and runs git, npm, gh, and coding-assistant CLIs during setup, upgrades, diagnostics, and bug reporting.
Files
Reads and indexes files in your project, its parent folder, and assistant instruction files; stores local search databases, command outputs, and logs in ~/.context-mode; and edits configuration, hook, and skill files across your home folder and VS Code settings.
Network
Fetches public web pages requested for indexing, connects to npm and GitHub to check versions, install updates, or submit bug reports, and allows any script it runs to make unrestricted network connections.
Secrets
Passes your environment variables, including any API keys or tokens in your environment, to the scripts and commands it runs, and reads assistant config files and logs (with partial token masking) when generating diagnostic reports.

Findings

5 high2 medium15 low
  1. HighOpenCode plugin skips shell permission checks for non-shell ctx_execute languages

    src/entries/opencode.ts:70

    In OpenCode, context-mode runs in-process and maps ctx_* calls to OpenCode permission checks so user rules such as shell ask or deny (or read-only plan mode) still apply. However, permissionRequests() only checks OpenCode's shell permission when isShellLanguage(language) is true (shell, sh, bash, zsh, dash, ksh, fish). Calling ctx_execute with language set to javascript, typescript, python, powershell, or another binary on PATH checks only the ctx_execute action—which falls through to OpenCode's catch-all * allow rule—and executes arbitrary host code and commands without triggering shell permission prompts or deny rules. Even for shell, shellRequest() uses parseShell() without unwrap(), so nested commands inside $(...) or sh -c are not unwrapped for command-pattern rules.

    Fix: Assert OpenCode's shell permission action for every ctx_execute call regardless of language, and pass unwrapped commands from unwrap(parsed.commands) as permission resources for shell scripts.

  2. HighBare node command in Windows hook configs allows CWD binary hijacking via cmd.exe

    src/setup/registry.ts:336

    On Windows, context-mode setup writes hook commands for codex, qwen, copilot-cli, and vscode using bare node instead of the resolved absolute path to node.exe. Hosts such as Qwen spawn hook commands through cmd.exe /d /s /c in the project working directory, and on Windows cmd.exe searches the current working directory for node.com, node.exe, node.bat, and node.cmd before searching PATH. Opening an untrusted repository containing one of those files in its root causes automatic hook events (SessionStart, UserPromptSubmit, PreToolUse) to execute the repository's binary without user approval or prompt injection.

    Fix: Use the resolved absolute path to node.exe in cmd.exe hook commands (and use the dedicated powershell field with '& "<node.exe>"' or an unquoted 8.3 path where PowerShell runs hooks) so cmd.exe never searches the project working directory.

  3. HighOpenCode shell permission rules bypassed via non-shell runtimes and missing-permission fallback

    plugins/claude-code/opencode/plugin.js:34098

    In the OpenCode in-process plugin, permissionRequests only checks OpenCode's shell permission rule when ctx_execute is called with a POSIX shell name (sh, bash, zsh, dash, ksh, fish, or shell). Calling ctx_execute with javascript, typescript, python, powershell, or another executable on PATH skips the shell permission check completely, allowing a prompt-injected agent or a restricted read-only subagent to run arbitrary commands despite a shell deny or prompt rule. In addition, shellRequest does not unwrap command substitutions such as $(...), and on OpenCode builds without ctx.permission.assert (permission === "missing"), execute skips permission checks instead of failing closed.

    Fix: Require OpenCode's shell permission check for every ctx_execute invocation regardless of runtime language, unwrap nested shell substitutions before checking command patterns, and refuse to run mutating or execution tools when host permission assertions are unavailable.

  4. HighCodex MCP configuration auto-approves unsandboxed code execution tools

    src/core/contracts/constants.ts:1033

    The README warns that ctx_execute runs unsandboxed on your host with your files, network, and environment variables, advising users to keep their agent's permission prompts on. However, both OWN_MCP_ENTRY.codex in src/core/contracts/constants.ts (written to ~/.codex/config.toml during setup and upgrades) and .codex-plugin/mcp.json set default_tools_approval_mode to approve for the entire context-mode MCP server. While intended to let read-only ctx tools run smoothly, setting this at the server level pre-approves every tool on the server, including ctx_execute and ctx_batch. If Codex reads untrusted text containing prompt injection, it can execute arbitrary host commands outside Codex's OS sandbox without any user confirmation prompt.

    Fix: Remove default_tools_approval_mode = approve from the server-level Codex MCP configuration in src/core/contracts/constants.ts and .codex-plugin/mcp.json, and instead set approval_mode = approve only on read-only tools such as ctx_search, ctx_resume, and ctx_stats.

  5. HighCodex plugin auto-approves all MCP tools including unsandboxed code execution

    plugins/claude-code/.codex-plugin/mcp.json:11

    The Codex plugin MCP configuration sets default_tools_approval_mode to approve, instructing Codex to run every context-mode tool without asking the user for permission. Because ctx_execute and ctx_batch run arbitrary commands and scripts on the host outside Codex's OS sandbox with full access to user files, network, and environment variables, prompt injection in a webpage, issue, or repository file read by the agent can silently execute arbitrary code, rewrite agent configs via ctx_upgrade, or exfiltrate secrets. This directly contradicts the README's security guidance, which tells users to keep their agent's permission prompts on because ctx_execute has no host isolation.

    Fix: Remove default_tools_approval_mode: approve from plugins/claude-code/.codex-plugin/mcp.json or restrict auto-approval strictly to read-only tools such as ctx_search and ctx_stats so ctx_execute, ctx_batch, ctx_upgrade, and ctx_purge require user confirmation.

  6. MediumFolder indexing in OpenCode checks read permission only on the directory path, not files inside it

    src/entries/opencode.ts:86

    In OpenCode, ctx_index can index an entire directory, but permissionRequests() only checks OpenCode's read permission against the top-level path argument and does not pass the permission callback into ToolContext. When a user configures file-pattern read deny rules in OpenCode (such as denying *.env or secrets/* while allowing *), a prompt-injected agent can call ctx_index with path set to '.'—which checks read only on the directory path itself—and then read the indexed contents of non-gitignored denied files through ctx_search.

    Fix: Pass the host permission check into ToolContext or enumerate target files before indexing so each file under a directory is checked against OpenCode's read permission rules.

  7. MediumIncomplete secret masking in ctx_doctor issue report generator

    src/core/ops/doctor-issue.ts:48

    When any check in ctx_doctor fails, writeIssueReport saves a pre-filled GitHub issue body to ~/.context-mode/reports/ including lines from hook-errors.log and agent config files, and prints a gh issue create command to publish it. Its redaction helper maskLine finds the cut point using Math.max(line.indexOf(":"), line.indexOf("=")). Whenever a line contains both : and =, it slices at whichever character appears later, leaving any secret before that point in cleartext. For example, a JSON line with base64 padding ("api_key": "secret=="), a hook-errors.log JSON entry whose error text has = after a token, or a TOML line with a URL after an API_KEY assignment will keep the full secret unmasked in the report file, and connection URLs like postgres://user:pass@host are not matched at all.

    Fix: Parse JSON and TOML config and log entries structurally and emit only an explicit allow-list of non-sensitive keys, matching the structural redaction approach already used in src/core/ops/report.ts.

  8. LowDeveloper benchmark and fixture scripts use a predictable directory in /private/tmp

    scripts/record-fixtures.mjs:40

    Developer-only scripts (scripts/record-fixtures.mjs, bench/replay.mjs, bench/saving-score.mjs, and bench/live/run.mjs) create and use a fixed path /private/tmp/cm-v2-impl-private for captured hook payloads, auth symlinks, and session transcripts. On a shared multi-user machine, another local user could pre-create that directory with permissive permissions to read session data or tamper with temporary hook configs when a developer runs those scripts; installed users never run them.

    Fix: Create temporary directories directly via fs.mkdtempSync(path.join(os.tmpdir(), 'cm-v2-')) or under the user's home directory instead of a fixed path in /private/tmp.

  9. LowProject containment root resolves to the git repository's parent directory

    plugins/claude-code/opencode/plugin.js:4949

    When resolving a git project's containment boundary, containmentRootOf strips .git to obtain repoDir and then passes dirname(repoDir) into commonRoot. This sets containmentRoot one directory level above the repository for every standard git checkout: if a repo is cloned in ~/my-app, containmentRoot becomes the user's entire home directory (~), and if cloned in ~/projects/my-app, it includes all sibling repositories. As a result, ctx_index and the file parameter of ctx_execute allow reading and indexing files outside the repository despite claiming to block paths outside the project.

    Fix: Pass repoDir rather than dirname(repoDir) into commonRoot (or restrict containment to the explicit list of git worktree directories rather than their shared ancestor directory).

  10. LowSSRF hostname check in safeFetch is skipped when HTTP_PROXY or HTTPS_PROXY is configured

    plugins/claude-code/opencode/plugin.js:29191

    The README states that URL fetching for ctx_index resolves each hostname, blocks private and link-local addresses, and re-checks at each redirect. However, when HTTP_PROXY or HTTPS_PROXY is set (and points to a non-private proxy such as an enterprise gateway on public IPv4 or global IPv6 space), safeFetch only checks current.hostname if it is already a literal IP address and only resolves proxy.url. Hostnames such as localhost, internal corporate names, cloud metadata hostnames, or DNS rebinding/nip.io domains—including via HTTP 302 redirects from an indexed public page—are forwarded to the proxy without SSRF validation.

    Fix: Resolve current.hostname and validate all returned addresses against checkAddress on every request and redirect hop even when routing through an HTTP or HTTPS proxy.

  11. LowUnbounded HTTP response body buffering in safeFetch

    plugins/claude-code/opencode/plugin.js:29178

    When ctx_index fetches a URL, readBody accumulates the entire HTTP response into an in-memory array of Buffers with no byte limit and a 10-minute timeout (EXEC_TIMEOUT_MS). Indexing a URL that serves a multi-gigabyte or streaming response can exhaust Node.js memory or fill ~/.context-mode/projects/<key>/context.db.

    Fix: Enforce a maximum response body byte limit in readBody and abort the request once the cap is exceeded.

  12. LowProject path containment includes parent folder and can expand to filesystem root

    src/core/project/resolve.ts:145

    ctx_index and the file parameter of ctx_execute check that requested paths stay inside project.containmentRoot, claiming to block paths outside the project. However, containmentRootOf computes commonRoot([dirname(repoDir), ...worktrees]), which always starts one directory above the repository. If a repository is cloned directly in your home folder (such as ~/my-app), containmentRoot becomes your entire home directory (including ~/.ssh and ~/.aws); if cloned in ~/projects/my-app, all sibling repositories are exposed. Furthermore, if the repository has a linked git worktree in another top-level folder such as /tmp, commonRoot resolves to /, allowing ctx_index to read and index any UTF-8 file on the machine.

    Fix: Store the list of allowed worktree roots ([repoDir, ...worktrees]) instead of a single lowest-common-ancestor path, and check file containment with isInsideAny(project.containmentRoots, abs).

  13. LowSubagent shell wrapper trusts caller-provided CLI argument for user deny rules

    src/core/tools/run-wrapper.ts:106

    In Claude Code subagent mode (Case B), the PreToolUse hook redirects shell commands to node run.mjs <base64-cmd> <base64-deny-rules>. Neither Claude Code's native permissions.deny rules nor the PreToolUse hook decode the base64 command passed to run.mjs; instead, runWrapperMain is supposed to enforce the user's deny policy before running the command. However, runWrapperMain reads those deny rules from argv[3] (supplied on the command line by the caller) rather than reading .claude/settings.json from disk. A prompt-injected subagent allowed to invoke run.mjs can pass W10= (base64 for an empty array []) as argv[3] to bypass all user Bash deny patterns and CONTEXT_MODE_REQUIRE_SECURITY=1.

    Fix: Load the user's deny rules directly from disk inside runWrapperMain via readUserDeny(project.worktree, RUN_WRAPPER_AGENT) instead of reading them from argv[3], and unwrap run.mjs arguments in PreToolUse.

  14. LowSSRF hostname checks in safeFetch are bypassed when HTTP_PROXY or HTTPS_PROXY is set

    src/core/sandbox/fetch.ts:242

    The README states that URL fetching in ctx_index checks every resolved IP address against private ranges on the initial request and on every redirect. However, when HTTP_PROXY or HTTPS_PROXY points to a reachable proxy, safeFetch only checks the target host if it is already an IP literal (isIP(origin) !== 0) and skips DNS resolution and private-IP validation for hostnames. If an indexed public web page responds with an HTTP redirect to http://localhost or an internal corporate hostname, safeFetch forwards that request through the proxy and indexes the response.

    Fix: Reject localhost and local domain suffixes before sending requests to a proxy, and resolve and validate target hostnames locally whenever DNS is available.

  15. LowUninstalling Gemini or Qwen extension follows symlinks and deletes target directory

    src/core/ops/uninstall.ts:76

    During ctx_upgrade in uninstall mode, removeCache calls resolvePluginRoot, which resolves symlinks via realpathSync.native. While the marketplace branch checks isInside(cache, root) so a linked local source directory is never deleted, the extension branch (used for Gemini CLI and Qwen Code) lacks this check and calls rmSync(root, { recursive: true, force: true }) directly on the resolved target path. If a user linked a local directory into ~/.gemini/extensions/context-mode (for example with gemini extensions link), uninstalling deletes the target source directory instead of removing only the symlink.

    Fix: Check lstatSync on the extension path before realpath resolution; if it is a symbolic link or resolves outside the host's extensions directory, unlink only the symlink or report it for manual removal.

  16. LowAgent instructions route web pages and file reads into arbitrary code execution

    src/prompt/instructions.md:3

    The server instructions tell the agent to use ctx_execute (arbitrary code and shell execution) whenever filtering or finding information in web pages or long files. For web pages, this steers the agent away from ctx_index (which enforces SSRF checks against private and link-local IP addresses) toward running curl or fetch directly on the host, as seen in the recorded benchmark traces. It also habituates users into approving code execution prompts for routine read-only tasks.

    Fix: Change src/prompt/instructions.md to direct web page lookups to ctx_index and ctx_search rather than ctx_execute so SSRF protections and read-only tool boundaries remain intact.

  17. Lowctx_execute tool description claims subprocess execution is sandboxed despite having no host isolation

    src/prompt/tools/ctx_execute.md:2

    The MCP tool description states that ctx_execute runs code in a sandboxed subprocess, and the plugin manifests advertise sandboxed code execution. As noted at the bottom of README.md, code actually runs directly on the host as the installing user with full access to local files, the network, and environment variables, and sandbox only refers to keeping stdout out of the chat window. Calling the subprocess itself sandboxed in the tool prompt can mislead both users reviewing approval prompts and the AI agent when deciding whether untrusted or destructive code is safe to run.

    Fix: Update src/prompt/tools/ctx_execute.md and plugin manifest descriptions to state clearly that code runs unsandboxed on the host as the current user and only its output is kept out of the conversation context.

  18. Lowctx_doctor tool prompt instructs the agent to run remediation commands without asking the user

    src/prompt/tools/ctx_doctor.md:2

    Although docs/tools.md documents ctx_doctor as read-only, its tool description instructs the agent to invoke ctx_doctor after any context-mode error and to run each suggested Fix command before calling ctx_doctor again, without asking for user approval first (unlike the gh issue step in the next sentence, which explicitly requires asking). If a check fails when a user only asked whether context-mode works or hit a transient error, the agent is directed to execute setup or upgrade commands that modify host configuration or install packages unasked.

    Fix: Change src/prompt/tools/ctx_doctor.md to instruct the agent to show failed checks and their suggested Fix commands to the user and ask for confirmation before running them.

  19. LowUnpinned remote install scripts in OMP installation guide

    docs/install/omp.md:10

    The OMP installation guide instructs users to pipe remote scripts from https://omp.sh/install and https://omp.sh/install.ps1 directly into sh and PowerShell without pinning a release ref or verifying a checksum. Although the installed plugin never runs these commands itself, anyone following this guide would execute arbitrary code if theomp.sh domain or CDN were compromised (whereas the project's own CI pins a version ref).

    Fix: Pin a specific release tag (for example passing --ref v18.20.0 as done in CI) and instruct users to download and verify the binary checksum before running it.

  20. LowCI and developer host-matrix script installs unpinned npm packages with lifecycle scripts enabled

    e2e/checks/windows-hosts.mjs:428

    This end-to-end test script is never shipped in the installed package and never runs on an end user's computer, so it cannot harm someone who simply installs context-mode. However, when a developer or CI runner executes this script, it installs the latest unpinned versions of seven third-party CLI packages from npm without --ignore-scripts and runs their binaries, exposing the test environment if any upstream package is compromised.

    Fix: Pin exact versions for the third-party CLI packages in HOSTS and pass --ignore-scripts when installing packages that do not require native postinstall builds.

  21. LowDeveloper live-test scripts write login credentials into predictable /tmp paths

    e2e/live/cache/codex.mjs:117

    When a developer manually runs the live Codex cache benchmark, it creates a fixed directory under /private/tmp/cm-v2-cp-cx/run using mkdirSync with default world-traversable permissions, copies the user's ~/.codex/auth.json token file into it, and leaves the copy behind on exit. A sibling live-test script (e2e/live/npm-package/claude-code.mjs) similarly uses mkdirSync on a predictable timestamped path in os.tmpdir() and writes the Claude Code Keychain OAuth credential before calling chmodSync. On a multi-user machine, another local user could pre-create those paths or read leftover files to access the developer's agent credentials. Normal users who install the plugin are not affected because the e2e suite is never shipped or executed at runtime.

    Fix: Create temporary test roots with fs.mkdtempSync so the directory is atomically created with 0700 permissions, pass { mode: 0o600 } when writing credential files, and delete the temporary directory in a finally block.

  22. LowDeveloper figure-rendering script loads Node modules from world-writable /tmp by default

    docs/assets/readme/src/render.mjs:18

    When PLAYWRIGHT_DIR is not set in the environment, this developer script falls back to '/tmp/web-sol/node_modules' and uses Node's createRequire to load 'playwright' and 'sharp' from there. On a shared Unix or macOS computer, another local user could pre-create '/tmp/web-sol/node_modules/playwright' with malicious JavaScript that runs under the developer's account if they execute render.mjs. Normal users who install the plugin never run this script.

    Fix: Remove the '/tmp/web-sol/node_modules' fallback so modules are resolved from the project's own node_modules or require PLAYWRIGHT_DIR to be explicitly set to a trusted directory.