Skip to content

Guards: fix post-merge review findings for MCP input checks - #10

Merged
dioptx merged 1 commit into
mainfrom
amp/mcp-guard-review-fixes
Nov 14, 2026
Merged

dioptx merged 1 commit into
mainfrom
amp/mcp-guard-review-fixes

Conversation

@dioptx

@dioptx dioptx commented Nov 14, 2026

Copy link
Copy Markdown
Owner

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:

  • Bash events changed (regression). wf.guard_blocked now 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.
  • subject key on non-MCP events (regression). A guard matching Read or another non-MCP tool by name added subject: "tool_name" to the event. The README says only MCP events carry subject; that is now true again.
  • False block on prose. {"transcripts": ["we agreed nobody runs git push on friday"]} blocked, because transcripts ends in scripts and counted as a command list. The singular transcript was already excluded; the plurals transcripts and postscripts are now excluded too.
  • Bypass via a structured body. {"path": "/containers/web/exec", "body": {"Cmd": ["git", "push"]}} was allowed. Any string path sibling made body/data/content/text count 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

  • An object-valued program beside args, such as {"command": {"path": "git"}, "args": ["push"]}, is still allowed. Failing closed here would block JSON-RPC-style calls whose command is an object. The bypass only works if a server reads {"path":"git"} as a program.
  • An integer longer than 4300 digits in the hook payload still exits 1 before any guard runs. The behaviour is the same on main before Guards: check commands inside MCP tool inputs (#2) #9, and Claude Code's JSON.stringify cannot produce such an integer.

Testing

  • python -m pytest -q: 2991 passed.
  • New cases cover the Bash and Read event schema, transcripts, and a structured body beside a path. Each fails on a5baed9 and passes here. The MCP cases run through both guard_engine.evaluate and hooks/weft-pretooluse.sh.

Amp thread: https://ampcode.com/threads/T-01a1d9bd-083a-72bf-a268-4630a34c91f2

- 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]>
@dioptx
dioptx merged commit cce02e8 into main Nov 14, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants