Skip to content

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

@Mishkun

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

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions