opencode icon indicating copy to clipboard operation
opencode copied to clipboard

No trusted workspace functionality leads to arbitrary commands execution on startup

Open Mishkun opened this issue 3 weeks ago • 2 comments

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

Mishkun avatar Dec 29 '25 14:12 Mishkun