fix(approval): add glob matching for command_allowlist entries - #9163
Open
richardiitse wants to merge 1 commit into
Open
fix(approval): add glob matching for command_allowlist entries#9163richardiitse wants to merge 1 commit into
richardiitse wants to merge 1 commit into
Conversation
command_allowlist entries (e.g. 'python3 << *') are glob patterns, but is_approved() was doing only set membership checks against pattern keys like 'script execution via heredoc', so allowlist entries never matched. Add fnmatch-based glob check before pattern-key lookup so glob entries in command_allowlist work as intended.
19 tasks
teknium1
reviewed
Jul 12, 2026
teknium1
left a comment
Contributor
There was a problem hiding this comment.
Thanks for identifying the command-text versus danger-key mismatch.
Problems
tools/approval.py:612matches the entire command with an unrestricted glob. That permits a pattern such aspython3 << *to span embedded newlines and shell syntax. Current main intentionally rejects compound commands before allowlist matching (tools/approval.py:1588-1607) and has regression coverage for chaining, pipes, redirects, newlines, backticks, and substitutions (tests/tools/test_command_guards.py:276-304).- The patch only covers
check_dangerous_command(). Current main uses its shared matcher from bothcheck_dangerous_command()andcheck_all_command_guards()(tools/approval.py:2276,tools/approval.py:2591).
Suggested changes
- A safe heredoc-specific policy would need a constrained parser-based design and tests rather than unrestricted full-command globbing.
Automated hermes-sweeper review.
| return {"approved": True, "message": None} | ||
|
|
||
| # Check glob-based allowlist BEFORE pattern-key lookup. | ||
| # command_allowlist entries like "python3 << *" are glob patterns, not pattern keys. |
Contributor
There was a problem hiding this comment.
fnmatch here runs against the whole shell string, so * can span newlines and shell operators. This would let a glob such as python3 << * approve appended/chained content; use a constrained matcher that rejects compound shell syntax before granting the shortcut.
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.
Problem
command_allowlistentries (e.g.python3 << *) are glob patterns, butis_approved()was doing only set membership checks against pattern keys likescript execution via heredoc. This means glob entries incommand_allowlistnever matched and commands always required approval.Fix
Add
fnmatch-based glob checking before the pattern-key lookup incheck_dangerous_command(). Now glob patterns likepython3 << *correctly bypass approval prompts.Testing
Files changed
tools/approval.py: +1 import (fnmatch), +6 lines (glob pre-check)