Skip to content

fix(gate): Monitor is a shell — govern it (v0.448.1) - #834

Merged
vikasprogrammer merged 1 commit into
mainfrom
feat/monitor-gate
Sep 18, 2026
Merged

vikasprogrammer merged 1 commit into
mainfrom
feat/monitor-gate

Conversation

@vikasprogrammer

Copy link
Copy Markdown
Owner

The hole. claude-code's Monitor tool takes an arbitrary shell command and streams its stdout as events. It was missing from gate-hook.sh's routing table AND from the PreToolUse matcher in claude-launch.sh, so it never reached the hook at all: no policy classification, no approval, no audit event, no host-egress governance.

Live evidence (recent transcripts, instapods + expresstech): ~30 Monitor calls including until ssh -o BatchMode=yes -i ~/.ssh/<key> root@<host> 'grep -q …', cat > /tmp/watch-multi.sh <<EOF, and token-minting scripts. Same class as the cross-session-messaging channel documented in CLAUDE.md.

The fix

  • Monitor added to the matcher and routed to shell.exec. Its tool_input.command has the same shape as Bash's, so enrichArgs computes identical facts with no server-side change.
  • The ws form (WebSocket, no command) is refused at the hook rather than sent on as a factless shell.exec that would read as allowed.

The test (scripts/gate-tool-coverage-test.cjs, new, wired into test:governance) drives the REAL hook as a subprocess against a stub gate: asserts every routed tool is reachable by the matcher, that Monitor arrives as shell.exec with its command text intact, and that ws is denied. Verified it fails on the pre-fix tree.

Note for reviewers: Monitor commands are now gated like Bash, so a risky one (ssh, destructive flags) can pause for approval where it previously ran silently.

🤖 Generated with Claude Code

claude-code's Monitor tool runs an arbitrary shell command and was in neither
the hook's routing table nor the PreToolUse matcher, so every call bypassed
policy, approval and audit. Route it to shell.exec, refuse the ws form, and add
gate-tool-coverage-test to pin matcher/table agreement.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@vikasprogrammer vikasprogrammer changed the title fix(gate): Monitor is a shell — govern it (v0.447.2) fix(gate): Monitor is a shell — govern it (v0.448.1) Sep 18, 2026
@vikasprogrammer
vikasprogrammer merged commit c792aaa into main Sep 18, 2026
1 check passed
@vikasprogrammer
vikasprogrammer deleted the feat/monitor-gate branch September 18, 2026 05:23
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.

1 participant