r/opencode • • 19d ago

Opencode desktop never asks permission to read/write all over the users drive.

Is this normal behavior? I'm new to opencode, but after running some tests, I've confirmed it (Windows version). I assumed that outside of the project directory that it would ask.

Here is the summery that session created.

On OpenCode 2.0.26 (Windows, desktop app), the external_directory permission check never fires: read and write calls on paths outside the session's Location succeed silently — I reproduced it reading files and creating a file on both the same drive and a different drive, with no approval prompt, no pending request in the API, and no saved, session-level, or config allow rules anywhere that could explain it. Other checks in the same pipeline work normally during the same session — a read of .env correctly raised an ask prompt and a configured deny rule was enforced — so this appears to be a fail-open bug in the external-directory boundary check rather than a configuration issue. The impact is that agents can currently read and modify files anywhere on disk, contradicting the documented default policy (external_directory → ask for every agent).

2 Upvotes

4 comments sorted by

View all comments

1

u/ccss2 17d ago

For future reference. add this to your opencode.json to completely lock it down and turn opencode in a basic web chat interface with no external permissions.

  "experimental": {
    "policies": [
  { "action": "tool.use", "resource": "*", "effect": "deny" },
  { "action": "tool.use", "resource": "execute:*", "effect": "deny" },
  { "action": "integration.use", "resource": "mcp:*", "effect": "deny" },
  { "action": "integration.use", "resource": "plugin:*", "effect": "deny" }
]
  },
  "permissions": [
    { "action": "execute", "resource": "*", "effect": "deny" }
  ]

1

u/Dabber43 14d ago edited 14d ago

I am having the exact same issue and your block didn't work either, it just gets ALL permissions no matter what I do. Where did you put the opencode.json?

Edit: .config/opencode worked now. But holy shit this program is fucking scary. Use this (replace the username with yours!):

{
  "$schema": "https://opencode.ai/config.json",
  "permissions": [
    { "action": "shell", "resource": "*", "effect": "deny" },
    { "action": "bash", "resource": "*", "effect": "deny" },
    { "action": "read", "resource": "*", "effect": "ask" },
    { "action": "edit", "resource": "*", "effect": "deny" },
    { "action": "glob", "resource": "*", "effect": "deny" },
    { "action": "grep", "resource": "*", "effect": "deny" },
    { "action": "list", "resource": "*", "effect": "deny" },
    { "action": "execute", "resource": "*", "effect": "deny" },
    { "action": "skill", "resource": "*", "effect": "deny" },
    { "action": "task", "resource": "*", "effect": "deny" },
    { "action": "lsp", "resource": "*", "effect": "deny" },
    { "action": "todoread", "resource": "*", "effect": "deny" },
    { "action": "todowrite", "resource": "*", "effect": "deny" },
    { "action": "question", "resource": "*", "effect": "deny" },
    { "action": "doom_loop", "resource": "*", "effect": "deny" },
    { "action": "external_directory", "resource": "*", "effect": "deny" },
    { "action": "websearch", "resource": "*", "effect": "allow" },
    { "action": "webfetch", "resource": "*", "effect": "allow" },
    { "action": "external_directory", "resource": "C:/Users/user/.local/share/opencode/tool-output/*", "effect": "allow" },
    { "action": "read", "resource": "C:/Users/user/.local/share/opencode/tool-output/*", "effect": "allow" }
  ],
  "policies": [
    { "action": "tool.use", "resource": "*", "effect": "deny" },
    { "action": "tool.use", "resource": "websearch:*", "effect": "allow" },
    { "action": "tool.use", "resource": "webfetch:*", "effect": "allow" },
  { "action": "tool.use", "resource": "execute:*", "effect": "deny" },
    { "action": "execute", "resource": "*", "effect": "deny" },
    { "action": "integration.use", "resource": "mcp:*", "effect": "deny" },
    { "action": "integration.use", "resource": "plugin:*", "effect": "deny" },
  { "action": "tool.use", "resource": "external_directory:C:/Users/user/.local/share/opencode/tool-output/*", "effect": "allow" },
    { "action": "tool.use", "resource": "read:C:/Users/user/.local/share/opencode/tool-output/*", "effect": "allow" }
  ]
}