Skip to content

[Repo Assist] fix(security): catch all-wildcard allow patterns in exec approval policy - #247

Merged
shanselman merged 1 commit into
masterfrom
repo-assist/fix-execapproval-wildcard-bypass-2026-04-30-3a61a9cd109f4085
May 1, 2026
Merged

[Repo Assist] fix(security): catch all-wildcard allow patterns in exec approval policy#247
shanselman merged 1 commit into
masterfrom
repo-assist/fix-execapproval-wildcard-bypass-2026-04-30-3a61a9cd109f4085

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

🤖 This is an automated PR from Repo Assist.

Problem

ValidateExecApprovalRules in SystemCapability guards against remote agents setting overly broad system.execApprovals.set policies, 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.

MatchesPattern converts "**" to the regex ^.*.*$, which matches every command string exactly like "*" does. An agent that can call system.execApprovals.set with a valid baseHash could 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:

// Strip every wildcard char ('*', '?') and whitespace; if nothing remains
// the pattern is an all-wildcard glob that matches any command.
var nonWildcardContent = normalized.Replace("*", "").Replace("?", "").Trim();
if (string.IsNullOrEmpty(nonWildcardContent))
    return $"Broad allow rule is not permitted: {pattern}";

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 the ExecApprovalsSet_RejectsUnsafeAllowRules theory.

Test Status

Suite Result
OpenClaw.Shared.Tests ✅ 1046 passed (+5 new), 5 pre-existing McpHttpServer failures, 20 skipped
OpenClaw.Tray.Tests ✅ 245 passed, 0 failed
./build.ps1 ⚠️ Not runnable on Linux CI; Shared build succeeded.

Generated by 🌈 Repo Assist, see workflow run. Learn more.

Generated by 🌈 Repo Assist, see workflow run. Learn more.

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/repo-assist.md@97143ac59cb3a13ef2a77581f929f06719c7402a

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>
@shanselman
shanselman marked this pull request as ready for review May 1, 2026 16:54
@shanselman
shanselman merged commit 4207163 into master May 1, 2026
3 checks passed
@shanselman
shanselman deleted the repo-assist/fix-execapproval-wildcard-bypass-2026-04-30-3a61a9cd109f4085 branch May 1, 2026 16:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant