Repository navigation
feat(approval): command-level allow/deny patterns for run_command - #453
Merged
Merged
Conversation
`run_command:<argv pattern>` in --allow / config allow matches run_command calls by the argv the tool executes (same splitter, no shell): one glob per argument, a final lone `*` = any further arguments, the program compared literally for an allow. A leading `!` makes any pattern a deny that wins over every allow and over --yes; a deny's program also matches by file name. While a run_command deny is set, wrapper programs (sh, env, sudo, xargs, ...) always ask the human. Denies travel with allow lists and children always inherit them. pattern_verdict is the one evaluation both approvers use.
🔍 Cora AI Code Review✅ No issues found. Code looks good! Review powered by cora-code · BYOK · MIT |
…overage (#438) Cora (alerts #118/#119) and the security review found three gaps in the first revision: - the child subset check globbed pattern TEXT, so a parent `run_command:*` (which allows nothing) "covered" a child `run_command:rm *`; pattern_covers now checks command patterns argument by argument with a literal program; - a deny compared the program case-sensitively with its extension, so `/bin/RM` or `rm.exe` escaped `rm *`; denies now compare the lowercased file name without .exe/.cmd/.bat/.com; - a wrapper denylist cannot be complete; while a command deny is set, a command now runs unattended only when an explicit `run_command:` allow names it (and never a wrapper); everything else asks.
Cora (alerts #120/#121) and the security review on dc8ece1: - a parent `?` matched a child's literal `*`, so `cat t?st` covered `cat t*st`; a child token with a wildcard is now covered only by the identical glob or a lone `*` (token_covers, also for tool names); - under a parent command deny the parent runs only explicitly allowed commands unattended, yet a bare `run_command` parent still covered a child `run_command:ls *`; list_covers now requires a parent `run_command:` allow there; - deny_only skipped the fail-closed rule; a `run_command:` deny there now refuses every run_command call (it has no allows to name safe commands).
This was referenced Oct 28, 2026
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
run_command:<argv pattern>allow patterns and!-prefixed deny patterns, so specific commands can be pre-authorized (or refused) without handing over the shell.Closes #438.
Why
--allowmatched tool names only:run_commandwas all-or-nothing (approve every call, or--yesfor every command). Headless/CI delegation needs "these commands are fine, those never".Changes
tole-core/src/approval.rs:pattern_verdict(patterns, req)— the one allow-list evaluation both approvers use: deny first, then the wrapper rule, then allow.run_command:<pattern>matches the argv fromRunCommandTool::split_argv, the same splitter the tool executes with (no shell:git status; rm -rf /cannot chain). Oneglob_matchper argument, a final lone*= any further arguments, otherwise equal arity. An ALLOW compares the program literally (/usr/bin/git≠git,run_command:*allows nothing).!prefix = deny (any pattern kind). A deny wins over every allow and over--yes; its program is a glob overargv[0]or its file name (/bin/rmcannot slip pastrm *).run_commanddeny is configured, known wrappers that can hide the real program (sh,bash,env,sudo,xargs,busybox,timeout, ...) returnAsk: the interactive approver prompts even under--yes; headless approvers refuse.deny_onlytreatsrun_command:patterns command-wise too.tole-cli/src/approver.rs:InteractiveApproverusespattern_verdict(deny > ask > allow >--yes> prompt).tole-core/src/agents.rs: a child always inherits every parent deny; deny patterns are exempt from (and never satisfy) the subset check.--denyfrom the issue is a!prefix in the existing allow list, so a deny travels everywhere allow patterns already go (configallow, ACP, serve, children) without new plumbing that could miss a path.docs/epics.md,docs/threat-model.md(allowlist is the boundary; a deny narrows--yesbut cannot make it safe; examples of argument-driven code execution such asgit -c …).Testing
;never chains, unterminated quotes never match, command patterns never match other tools, deny wins and sees through paths, wrappers →Ask(and → Deny headless),deny_onlycommand-wise, deny patterns never allow.--yeswithout prompting; a wrapper under a command deny prompts even under--yes.cargo fmt, clippy (workspace all-targets, bare, shell-tools, mcp, tole-core bare),cargo test --workspace: green. Cora agent review (prepare + finalize): 1 infoqual-clonerejected (the clone builds the child's list),should_block: false.