Skip to content

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

Closed as not planned

Description

@francesco-taurino

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

Activity

  1. github-actions commented on Aug 24, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

    If these cover your case, consider adding a "+1" reaction or additional context there rather than opening a new report.

  2. thdxr commented on Oct 11, 2026

    @thdxr
    Member

    Thanks for the report! OpenCode 2.0 is now out and development is focused on V2, so we're closing issues filed against OpenCode 1. Please upgrade (opencode upgrade --major, details: https://anoma.ly/notes/opencode-2-0), and if this is still relevant on 2.0, reopen this issue or open a new one with your 2.0 version.

    — from 𝕺𝖕𝖊𝖓𝕮𝖔𝖉𝖊

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions