anomalyco / anomalyco/opencode

external_directory: "deny" gets bypassed depending on which bash command you use (macOS)

Open
#44,728 1 comment 0 reactions 1 assignee View on GitHub

@kitlangton is already working on this.

Since Aug 24, 2026.

Dominant language
TypeScript
Stars
209k
Forks
27.5k
PR merge metrics
PR metrics pending

Description

Description

Found something inconsistent with external_directory: "deny". Same external path, same config, but whether it gets blocked depends entirely on which command touches it.

Config (project and global, identical):

{
  "permission": {
    "bash": {
      "*": "deny",
      "ls *": "allow",
      "cat *": "allow",
      "head *": "allow",
      "tail *": "allow",
      "grep *": "allow",
      "rg *": "allow",
      "find *": "allow"
    },
    "external_directory": "deny"
  }
}

Running opencode from /Users/<user>/myapp:

  • read tool on /etc/hosts → blocked ✓
  • cat /etc/hosts → blocked ✓
  • head -1 /etc/hosts → just runs, dumps the content, no prompt at all
  • ls /etc/hosts → runs
  • ls /etc → runs, full directory listing

So cat gets stopped but head and ls walk right past the same deny rule on the same path. That shouldn't be possible — if external_directory is deny, it shouldn't matter which command is asking.

Related: #17497, #16126, #36681 - those are closed as not planned ("ask" case / Windows), this is different: "deny" on macOS, per-command inconsistency.

Plugins

none

OpenCode version

1.18.21

Steps to reproduce
  1. Apply the config above in both the project opencode.json and ~/.config/opencode/opencode.jsonc, then clear the cache (rm -rf ~/.cache/opencode) and restart opencode.
  2. Start opencode from /Users/<user>/myapp.
  3. Ask the agent to run head -1 /etc/hosts → it executes and prints the content, no prompt, no block (BUG).
  4. Ask the agent to run ls /etc → it executes and lists the directory (BUG).
  5. Ask the agent to run cat /etc/hosts → blocked (correct — proves the config is enforced for some commands).
  6. Ask the agent to read /etc/hosts with the read tool → blocked (correct).
Screenshot and/or share link
Image Image
Operating System

Mac Os Ventura 13.6.6

Terminal

Apple Terminal

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.