Skip to content

Reject mutating webhook patches that rewrite tool name or method - #6938

Open
Tyagiquamar wants to merge 1 commit into
stacklok:mainfrom
Tyagiquamar:fix/6134-reject-tool-rename-patches
Open

Tyagiquamar wants to merge 1 commit into
stacklok:mainfrom
Tyagiquamar:fix/6134-reject-tool-rename-patches

Conversation

@Tyagiquamar

@Tyagiquamar Tyagiquamar commented Oct 25, 2026 •

Copy link
Copy Markdown

Summary

A mutating webhook cannot rewrite the MCP tool name or the MCP method. Those patches are rejected.

Root cause

Tool filtering and rate limiting run before mutation. A patch of /mcp_request/params/name or /mcp_request/method could change the name or method after those checks, so a blocked tool or method still ran.

Solution

Patch scope validation fails closed on those paths. Tests that previously allowed the rewrite now expect rejection.

Test plan

pkg/webhook/mutating/patch_test.go and pkg/webhook/mutating/middleware_test.go cover a name rewrite and a method rewrite.

Fixes #6134

Tool filtering and rate limiting run before mutation, so allowing
/mcp_request/params/name or /mcp_request/method patches would bypass
those controls. Fail closed at patch scope validation and update tests.

Fixes stacklok#6134
@Tyagiquamar
Tyagiquamar requested a review from JAORMX as a code owner October 25, 2026 15:37
@ChrisJBurns

Copy link
Copy Markdown
Collaborator

@Tyagiquamar Could you add a PR description to detail what your PR aims to do?

This branch has not been deployed

No deployments
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.

Tool filtering and rate limiting are enforced against the pre-mutation request

2 participants