Repository navigation
Guards: fix post-merge review findings for MCP input checks - #10
Merged
Merged
Conversation
- Bash and other non-MCP guard events again record the full command and no subject key, matching the event schema before MCP input checking. - transcripts/postscripts lists no longer start command-list context. - Only string body/data/content/text beside a path is skipped as file data; object or list values, such as an HTTP request body, are checked. Amp-Thread-ID: https://ampcode.com/threads/T-01a1d9bd-083a-72bf-a268-4630a34c91f2 Co-authored-by: Dennis Pettas <[email protected]>
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.
Follow-up to #9, from a post-merge review of a5baed9. The review found no MCP command that gets past the hook and no case where a block exits 1 instead of 2. It did find these issues, all fixed here:
wf.guard_blockednow cut a refused Bash command to 2000 characters, while the agentry mirror kept the full string. Bash/Edit/Write events record the full command again, as they did before Guards: check commands inside MCP tool inputs (#2) #9. Only MCP events are truncated.subjectkey on non-MCP events (regression). A guard matchingReador another non-MCP tool by name addedsubject: "tool_name"to the event. The README says only MCP events carrysubject; that is now true again.{"transcripts": ["we agreed nobody runs git push on friday"]}blocked, becausetranscriptsends inscriptsand counted as a command list. The singulartranscriptwas already excluded; the pluralstranscriptsandpostscriptsare now excluded too.{"path": "/containers/web/exec", "body": {"Cmd": ["git", "push"]}}was allowed. Any stringpathsibling madebody/data/content/textcount as file data, even when the value was an object. Only string values are skipped now.The README also now documents one known false block: a complete JSON document under a non-path content key, such as an edit's
newText, is decoded and can block.Not changed
{"command": {"path": "git"}, "args": ["push"]}, is still allowed. Failing closed here would block JSON-RPC-style calls whosecommandis an object. The bypass only works if a server reads{"path":"git"}as a program.JSON.stringifycannot produce such an integer.Testing
python -m pytest -q: 2991 passed.transcripts, and a structured body beside a path. Each fails on a5baed9 and passes here. The MCP cases run through bothguard_engine.evaluateandhooks/weft-pretooluse.sh.Amp thread: https://ampcode.com/threads/T-01a1d9bd-083a-72bf-a268-4630a34c91f2