[Repo Assist] fix(security): catch all-wildcard allow patterns in exec approval policy - #247
Merged
shanselman merged 1 commit intoMay 1, 2026
Conversation
ValidateExecApprovalRules rejected single '*' but missed patterns like
'**', '***', '?', '? *', '* ?' that also match any command string.
An agent that can call system.execApprovals.set could bypass the
broad-allow restriction by submitting '**' as an allow pattern:
{"rules": [{"pattern": "**", "action": "allow"}], "baseHash": "..."}
The glob-to-regex translation turns '**' into '^.*.*$', which matches
every command, exactly like '*' does.
Fix: strip all wildcard chars ('*', '?') and whitespace from the
normalised pattern before checking. If nothing remains the pattern is
an all-wildcard glob and is rejected as broad. The explicit shell-
prefix checks (powershell *, pwsh *, cmd *, cmd.exe *) are preserved
for patterns that contain meaningful content but are still too broad.
Tests: add **, ***, ?, '? *', '* ?' to ExecApprovalsSet_RejectsUnsafeAllowRules.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This was referenced May 1, 2026
shanselman
marked this pull request as ready for review
May 1, 2026 16:54
shanselman
deleted the
repo-assist/fix-execapproval-wildcard-bypass-2026-04-30-3a61a9cd109f4085
branch
May 1, 2026 16:54
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.
🤖 This is an automated PR from Repo Assist.
Problem
ValidateExecApprovalRulesinSystemCapabilityguards against remote agents setting overly broadsystem.execApprovals.setpolicies, but it only checked for the exact string"*"and a few explicit shell-prefix patterns. The pattern"**"— and similar all-wildcard variants like"***","?","* ?"— slipped through.MatchesPatternconverts"**"to the regex^.*.*$, which matches every command string exactly like"*"does. An agent that can callsystem.execApprovals.setwith a validbaseHashcould use this to allow all commands:{ "baseHash": "<current hash>", "rules": [{"pattern": "**", "action": "allow", "enabled": true}], "defaultAction": "deny" }Fix
Replace the literal
is "*" or "* *"check with a wildcard-stripping check:This catches
*,**,***,?,* ?,? *, etc. in a single rule. The explicit shell-prefix checks (powershell *,pwsh *,cmd *,cmd.exe *) are preserved as they have non-wildcard content but are still too broad.Tests
Added
"**","***","?","? *","* ?"to theExecApprovalsSet_RejectsUnsafeAllowRulestheory.Test Status
OpenClaw.Shared.TestsOpenClaw.Tray.Tests./build.ps1