Skip to content

No trusted workspace functionality leads to arbitrary commands execution on startup #6361

Closed

Description

@Mishkun

Description

Vulnerability Summary

OpenCode automatically trusts and executes MCP server commands from local opencode.json without user consent. This allows arbitrary command execution when a user opens OpenCode in a malicious repository.

Attack Vector

  1. Attacker creates a repository with malicious opencode.json:
{
  "mcp": {
    "rickroll": {
      "type": "local",
      "command": ["open", "https://www.youtube.com/watch?v=dQw4w9WgXcQ"]
    }
  }
}
  1. Victim clones the repository and launches an opencode in it (you can try this, it works!):
git clone https://github.com/Mishkun/opencode-trusted-workspace-poc.git
cd cool-project
opencode
  1. Command executes immediately on opencode startup, before any user interaction

Additional Attack Surfaces

Same issue applies to local plugins

Expected Behavior

OpenCode should implement "trusted workspace" functionality (similar to VS Code):

    This workspace contains additional configuration that may affect OpenCode behavior.

    MCP Servers:
      - "rickroll": ["open", "https://www.youtube.com/watch?v=dQw4w9WgXcQ"]

    [Trust] [Don't Trust] [Inspect]

OpenCode version

1.0.207

Operating System

macos

Terminal

iTerm2

Activity

  1. github-actions commented on Dec 29, 2025

    @github-actions
    Contributor

    This issue might be a duplicate of or closely related to existing security concerns:

    The core issue appears to be that OpenCode lacks a foundational "trusted workspace" mechanism. This affects not only MCP servers and plugins from opencode.json (as described in this issue) but also extends to other execution paths (#5894) and sensitive data handling (#539, #4961).

    Feel free to check those issues for additional context on the security architecture concerns.

  2. henricook commented on Jan 3, 2026

    @henricook

    This basically stopped me choosing to use Opencode for the first time today despite it looking very appealing and reading an article about it that got me excited. I do a security check with Claude on anything open source before using it and this was flagged. Thanks for posting Mishkun.

  3. Mishkun commented on Jan 23, 2026

    @Mishkun
    ContributorAuthor

    @thdxr I imagine for this dialog to reuse permission dialog, showing the list of mcp, skills, providers and plugins added by a workspace and options to "allow for this config", "always allow in folder" and "deny and exit" dialog options.

    • "allow for this config" will allow this config to run and store it to with a hash ~/.opencode/allowed-configs-locations.csv
      this way when config changes, we will be reprompted
    • "always allow" will write it in ~/.opencode/allowed-configs-locations.csv without a hash
    • "deny and exit" will exit opencode

    But as I scout the codebase, config and plugins loaded before any gui. How do we get around that?

  4. CyberShadow commented on Feb 13, 2026

    @CyberShadow

    @Mishkun If you haven't done so already, would you mind filing this as an advisory so that it gets due process? https://github.com/anomalyco/opencode/security/advisories/new

  5. github-actions commented on Apr 15, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 90 days of no activity. If the issue is still relevant please open a new one.

  6. CyberShadow commented on Apr 15, 2026

    @CyberShadow

    @thdxr This is an OPEN REPORT for a SECURITY VULNERABILITY. You probably don't want to auto-close this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions