Repository navigation
fix(gemini): require approval for Gemini web fetches and MCP resource reads - #1216
Conversation
Generated-by: Codex (GPT-6)
|
Very cool |
|
LGTM thanks! |
potiuk
left a comment
There was a problem hiding this comment.
Reviewed against the branch locally, drove the sandbox-lint invariants by hand, and verified the premise against upstream rather than the PR description. LGTM — the change is correct and strictly narrows the posture.
Verification
packages/core/src/policy/policies/read-only.toml at v0.59.0 lists read_mcp_resource and list_mcp_resources — alongside google_web_search — in the built-in read-only allow block at priority 50, i.e. default tier 1.050. The new User-tier rules land at 4.600 and win in every mode, so this is a narrowing in Plan Mode too, not a widening. web_fetch is not in that list, consistent with the claim that it was the auto-edit allowance doing the work there. All three names are real constants in tool-names.ts at that tag, so the ALL_BUILTIN_TOOL_NAMES assertion in the probe will hold.
I exercised check_gemini_invariants directly against the branch profile: baseline is clean, and all 15 mutation cases (3 tools x missing / allow / default_only / interactive_only / args_only) produce the expected error. The query_only -> args_only rename is just the parametrisation generalising past the web-search-specific name.
The new priority assertion is the best part of the diff. Pinning result.rule?.priority === USER_POLICY_TIER + 0.6 across all four modes catches the silent-widening case where a future built-in rule outranks the shipped one and the decision still happens to read ask_user.
Non-blocking notes
-
The strongest guard is opt-in. The auto-edit override for
web_fetchis the actual security claim here, and the only thing proving it isgemini_runtime.mjs, which skips unlessMAGPIE_GEMINI_BUNDLEis set.sandbox-lintcan assert the rule exists, not that it outranks the built-in. That is the pre-existing pattern from thegoogle_web_searchwork, so not a regression — but it does mean every Gemini upgrade needs a manual probe run, which is worth stating explicitly somewhere durable. -
The samples are not schema-validated.
web_fetchandread_mcp_resourceare not in theschemasmap, so{ prompt: ... }and{ uri: ... }are never checked against the runtime's declared parameters — an upstream argument rename would pass silently. It does not affect matching today (neither rule usesargsPattern), but the file already has the machinery and this PR is precisely about asserting against the real runtime. Cheap to add. -
Linter error string.
web_fetch/read_mcp_resourcenow inherit"(shell requires the command argument matcher)", which is nonsense for them. Pre-existing forwrite_file/replace, but the loop is up to six tools with one shell-specific parenthetical. -
Worth a sentence in the docs: leaving
list_mcp_resourcesallowed discloses the configured servers' resource registry to the model without approval. Low risk and the doc is explicit — but the stated justification ("lists the cached resource registry without making a resource-read request") is an assertion about upstream behaviour that nothing in the suite pins.
Nice cross-adapter consistency, worth calling out: sandbox_lint/kiro.py already flags auto-approved web_fetch as "an exfiltration channel". This brings Gemini in line with a posture Magpie enforces elsewhere.
Generative AI disclosure: this review was prepared with Claude Code (Opus 5); the upstream claims above were verified against google-gemini/gemini-cli sources at v0.59.0.
Summary
web_fetchwithout approval in auto-edit. Nativeread_mcp_resourcealso defaults to allow and does not match Magpie's MCP server-tool wildcard.Type of change
.claude/skills/<name>/) — eval fixtures updated belowtools/<system>/*.md)tools/*/withpyproject.toml)docs/,README.md,CONTRIBUTING.md)projects/_template/)prek, workflows, validators)Test plan
prek run --all-filespassesRFC-AI-0004 compliance
<PROJECT>,<tracker>,<upstream>,<security-list>) used in all skill / tool proseLinked issues
Ref: #314
Notes for reviewers (optional)
Plan Mode permits these reads with approval to support gathering context; ordinary MCP server tools remain denied there. The tests evaluate native policy decisions without authenticated model calls.
Generative AI disclosure: Codex (GPT-6) assisted with implementation, documentation, tests, and preparation of this PR description.
Screenshots
By default,
read_mcp_resourceisallowin all modes, andweb_fetchisallowin auto-edit mode.web_fetchruns without explicit asking for approval in auto edit mode.read_mcp_resourcealso runs without explicit asking for approval indefaultapproval mode.The PR fixes the above by enforcing it to ask for approval through policies.