Skip to content

Permission pattern matching silently ignores commands containing '--' #27575

Closed

Description

@harvzor

Description

Bash permission rules containing -- in the pattern are silently ignored — the command runs without triggering the configured ask or deny action.

Config

"permission": {
  "bash": {
    "chezmoi git -- push": "ask",
    "chezmoi git -- push *": "ask"
  }
}

Steps to reproduce

  1. Add the above permission rules to opencode.json (tested at both top-level and per-agent level)
  2. Run chezmoi git -- push via the bash tool
  3. The command executes without any permission prompt

Expected behaviour

The command should trigger an ask prompt before executing.

Additional context

  • Patterns without -- work correctly. For example, "git push": "ask" triggers the prompt as expected.
  • Workaround: use "chezmoi git *": "ask" which matches without relying on the -- literal.
  • The -- is likely being interpreted as an argument separator by the glob matcher rather than matched as a literal string.

OpenCode version

Latest (tested 2026-05-14)

Operating System

Windows 11

Activity

  1. github-actions commented on May 14, 2026

    @github-actions
    Contributor

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

  2. harvzor commented on May 14, 2026

    @harvzor
    Author

    ngl my agent created this issue without asking me - I've been working on making its permissions less permissive and apparently I need to block its easy access to gh

  3. harvzor commented on May 14, 2026

    @harvzor
    Author

    I think the issue still stands but I don't feel confident enough to file an issue

  4. harvzor commented on May 14, 2026

    @harvzor
    Author

    Update: root cause found

    Further testing shows the issue is broader than just --. Even "chezmoi *": "ask" and "chezmoi git *": "ask" fail to block chezmoi git -- push.

    This appears to be the same root cause as the closed issue #6676 — the bash tool uses treesitter to tokenize commands before permission matching, and skips certain node types. The -- token is stripped during tokenization, so chezmoi git -- push is evaluated as if it were chezmoi git push.

    Confirming the treesitter theory: the pattern "chezmoi git push": "ask" (without --) does block chezmoi git -- push. This confirms -- is being dropped before pattern matching occurs.

    So #6676 was closed but the fix was incomplete — it only addressed the kill -9 style flags, not -- argument separators.

  5. m21-cerutti commented on Jul 15, 2026

    @m21-cerutti

    I confirm it still exist, in my case it was git status --porcelain, even defining without wildcard is not working (of course I restarted my session after permission update).

    Image
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