-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Description
Description
Bash permission patterns using wildcards appear to not match commands that include flags or arguments in certain positions.
Configuration:
"permission": {
"bash": {
"kill *": "ask",
"pkill *": "ask"
}
}Expected behavior: Running kill -9 44165 should prompt for permission ("ask")
Actual behavior: The command executes immediately without prompting, even though the pattern "kill *" should match kill -9 44165
Possible cause (unconfirmed): After investigating the codebase, we noticed that the bash tool in packages/opencode/src/tool/bash.ts uses a whitelist of treesitter node types when extracting command tokens for permission matching:
if (
child.type !== "command_name" &&
child.type !== "word" &&
child.type !== "string" &&
child.type !== "raw_string" &&
child.type !== "concatenation"
) {
continue;
}It's possible that flags like -9 are parsed as argument nodes by treesitter, which would cause them to be skipped during extraction. This could result in the command string being truncated to just "kill", which wouldn't match the pattern "kill *" (due to the literal space). The system might then fall back to the default "*": "allow" rule.
Note: This is speculative based on code review - we haven't confirmed this is the definitive root cause.
OpenCode version
1.0.224
Steps to reproduce
- Add this to
opencode.json:
"permission": {
"bash": {
"kill *": "ask",
"pkill *": "ask"
}
}- Start OpenCode and ask the agent to kill a process by PID
- Observe that
kill -9 <PID>executes without prompting for permission
Screenshot and/or share link
No response
Operating System
macOS
Terminal
Ghostty
🤖 This content was generated with AI assistance using Claude Opus 4.5 (Thinking).