Fix: agent not able to execute shell command added to customAllowPatterns - #3314
Open
j-v wants to merge 1 commit into
Open
Fix: agent not able to execute shell command added to customAllowPatterns#3314j-v wants to merge 1 commit into
j-v wants to merge 1 commit into
Conversation
This was referenced Aug 3, 2026
|
This PR has had no activity for 7 days and has been marked as stale. If you are still working on it, please push an update or leave a comment; otherwise it will be closed automatically in 7 days. |
Author
|
Still active, waiting for review |
This was referenced Aug 10, 2026
This was referenced Aug 11, 2026
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.
📝 Description
Bug: My agent was not able to execute 'git push' despite adding it to the exec allow list. According to the tests it should have worked.
Fixed
customAllowPatternsnot working: default deny patterns always took precedence inguardCommand, so a command likegit pushcould never be permitted via a custom allow pattern. Separated user-specifiedCustomDenyPatternsfrom the built-in defaults so security-critical custom deny rules (e.g. jq env-access checks) still always apply, while built-in deny patterns can be exempted by a matching custom allow pattern.Also fixed
TestShellTool_CustomAllowPatterns, which previously passed vacuously: it never set an internal channel context, so the channel-restriction check blocked the command before the guard ran. The test now reachesguardCommandand genuinely asserts the allow/deny behavior (allowed with pattern, blocked without, blocked for non-matching remote).🗣️ Type of Change
🤖 AI Code Generation
🔗 Related Issue
N/A
📚 Technical Context (Skip for Docs)
guardCommandchecked all deny patterns (built-in + userCustomDenyPatterns) before any allow logic, andcustomAllowPatternswere only consulted bycommandMatchesAllowPattern, which is gated onallowPatternsbeing non-empty (never populated in practice) — making custom allow rules dead code. The fix splits deny patterns into built-in (denyPatterns) and user-specified (customDenyPatterns) lists. Built-in deny patterns (e.g.\bgit\s+push\b) can now be exempted by a matching custom allow pattern, but custom deny patterns always apply so operators can't weaken explicit security rules (see [Security] PicoClawexeccommand whitelist allows jq environment disclosure by skipping deny-pattern enforcement #3079). The existing test appeared to pass but never exercised the guard due to the channel check firing first on an empty channel context.🧪 Test Environment
📸 Evidence (Optional)
Click to view Logs/Screenshots
Without the fix (shell.go reverted), `TestShellTool_CustomAllowPatterns` fails: ``` === RUN TestShellTool_CustomAllowPatterns shell_test.go:682: custom allow pattern should exempt 'git push origin main', got: Command blocked by safety guard (dangerous pattern detected) --- FAIL: TestShellTool_CustomAllowPatterns (0.00s) ``` With the fix: ``` === RUN TestShellTool_CustomAllowPatterns --- PASS: TestShellTool_CustomAllowPatterns (1.33s) === RUN TestShellTool_CustomAllowDoesNotBypassDenyPatterns --- PASS: TestShellTool_CustomAllowDoesNotBypassDenyPatterns (0.00s) === RUN TestShellTool_CustomAllowStillPermitsSafeMatch --- PASS: TestShellTool_CustomAllowStillPermitsSafeMatch (0.00s) === RUN TestShellTool_CustomAllowDoesNotBecomeStrictAllowlist --- PASS: TestShellTool_CustomAllowDoesNotBecomeStrictAllowlist (0.00s) ```☑️ Checklist