GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||||
GeezerVison is showing github.com — Disable auto-approval of project MCP servers when .mcp.json changes in PR by ashwin-ant · Pull Request #942 · anthropics/claude-code-action Conversation
Collaborator
What and whyWhen a PR modifies This PR makes auto-approval conditional: if Changes
|
Code Review SummaryThe security motivation here is sound — auto-approving project MCP servers when Must fix
Should fix
Consider
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
…n PR When a PR modifies .mcp.json, the checked-out working directory contains a version that may differ from the base branch. Blindly setting enableAllProjectMcpServers=true in that context auto-approves those MCP servers without the user having reviewed them. Fix: before calling setupClaudeCodeSettings, check whether .mcp.json changed in the triggering PR using the GitHub REST API (pulls.listFiles). If it did, pass mcpJsonChanged=true to suppress the enableAllProjectMcpServers=true override. When .mcp.json is unmodified (the common case), behaviour is unchanged. - Add mcpJsonChanged parameter to setupClaudeCodeSettings - Add PR file-list check in src/entrypoints/run.ts - Update tests: update existing override test, add two new mcpJsonChanged=true tests
- Use octokit.rest.paginate() to fetch all pages of PR changed files, preventing attackers from padding PRs with 100+ files to push .mcp.json off the first page - Change catch block to fail closed (mcpJsonChanged=true) so MCP servers are not auto-approved when the API call fails
3b21ebf to
f4ac33b
Compare
|
@claude review |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
Claude finished @km-anthropic's task in 1m 39s —— View job Code Review for PR #942
Good security motivation — preventing auto-approval of MCP servers when Must fix1. Broken call site in
await setupClaudeCodeSettings( process.env.INPUT_SETTINGS, undefined, // homeDir ); After the signature change to await setupClaudeCodeSettings( process.env.INPUT_SETTINGS, false, // mcpJsonChanged — standalone base-action doesn't detect PR changes undefined, // homeDir ); Should fix2. User In The } else { delete settings.enableAllProjectMcpServers; console.log( `Removing enableAllProjectMcpServers because .mcp.json changed in this PR`, ); } 3. Missing test for Tests cover the cases where input doesn't set Status of prior review items
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
The pagination and fail-closed fixes address two of my earlier findings — thanks for that. Two issues remain: the base-action/src/index.ts call site still has a stale // homeDir comment and skips the new mcpJsonChanged parameter (works by accident), and the else branch in setup-claude-code-settings.ts still doesn't delete settings.enableAllProjectMcpServers when mcpJsonChanged is true, so user input with enableAllProjectMcpServers: true can bypass the protection.
This PR adds a security check to disable auto-approval of project MCP servers when .mcp.json is modified in a PR. It touches three files: setup-claude-code-settings.ts (new mcpJsonChanged parameter), run.ts (detection logic using GitHub API), and the test file.
Two of my four critical findings from the initial review have been fixed:
octokit.rest.paginate instead of a single listFiles callmcpJsonChanged = trueBoth fixes match the suggestions I provided.
Call site in base-action/src/index.ts (not in PR diff): Line 16 still passes undefined with the comment // homeDir, but after the signature change undefined now maps to mcpJsonChanged. This works by accident (falsy = false = old behavior), and homeDir uses its default. The comment is incorrect and the behavior is fragile.
Security gap: When mcpJsonChanged is true, the else branch only logs a message. It does not delete settings.enableAllProjectMcpServers. If the user's INPUT_SETTINGS includes enableAllProjectMcpServers: true, the merge on line 59 ({ ...settings, ...inputSettings }) will have already set it, and the else branch won't remove it — effectively bypassing the protection this PR is meant to provide.
This PR is explicitly a security mitigation against RCE via malicious MCP servers in PRs. The remaining security gap (#2 above) means the protection can be circumvented if a workflow happens to set enableAllProjectMcpServers: true in its settings input. While this requires a specific workflow configuration, it undermines the security invariant the PR is trying to establish.
High — this is security-critical code that guards against RCE. The fixes so far are good, but the remaining gap in the else branch should be addressed before merging.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
When mcpJsonChanged is true, delete enableAllProjectMcpServers from the merged settings object so user-provided INPUT_SETTINGS cannot re-enable it and bypass the check. Also fix the stale positional arg in the standalone base-action call site and add test coverage for the bypass case.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
All 5 issues from my prior reviews are now resolved (index.ts call site, pagination, fail-closed, settings override, missing test). Deferring to human review since this touches security-sensitive MCP server auto-approval logic.
This PR adds a security guard: when a PR modifies .mcp.json, the action skips auto-approving project MCP servers to prevent RCE via attacker-injected MCP configurations. It touches 4 files: run.ts (detection logic), setup-claude-code-settings.ts (conditional approval), index.ts (call site update), and the test file.
All 5 must-fix/should-fix items from my two prior reviews are now resolved:
index.ts call site — Now passes false explicitly with correct commentoctokit.rest.paginate to fetch all changed filesmcpJsonChanged=true (fail-closed)else branch now does delete settings.enableAllProjectMcpServersenableAllProjectMcpServers: true + mcpJsonChanged: trueThe two remaining "consider" items (positional boolean parameter, no unit test for run.ts detection logic) are style/coverage suggestions, not correctness issues.
The PR is a security improvement. The implementation correctly handles the key attack vectors: large PRs (pagination), API failures (fail-closed), nested .mcp.json paths, and user settings bypass. One residual limitation is GitHub's hard cap of 3,000 files per PR via the API, but this is an API-level constraint.
This modifies security-sensitive logic controlling which MCP servers are auto-trusted. While the implementation is now correct and well-tested, a human should verify the security design decisions (fail-closed behavior, scope of .mcp.json path matching, interaction with other settings).
Test coverage is comprehensive for the settings logic. The detection logic in run.ts lacks direct unit tests but is straightforward. A human reviewer (ddworken) confirmed two of the original bugs. The PR description accurately reflects the changes.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Pull request was closed
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.