Repository navigation
fix(mcpbroker): rate-limit the embedded authorization server's routes - #2781
Closed
ChrisJBurns wants to merge 1 commit into
Closed
ChrisJBurns wants to merge 1 commit into
ChrisJBurns wants to merge 1 commit into
Conversation
Co-authored-by: Mecatl <[email protected]>
Contributor
Author
|
Closing: rate limiting for the embedded gateway's routes moves to phase 2 (#2558). It will be redone from scratch then. |
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #2772.
What
The MCP broker's embedded authorization server (AS-2 when the identity broker is on) served its anonymous OAuth routes with no rate limit and no query cap. They now get the same bounds as AS-1:
/oauth/tokenin its own bucket, the other auth-server routes (authorize, consent, upstream callback, discovery, JWKS, protected-resource metadata) in a separate sign-in bucket. Past a budget:429.414; bodies capped at 64 KiB.The limits are applied where the handlers are built (
internal/adapter/mcpbroker/toolhive_process.go), so every mount gets them: mecak8s, mecated, andinternal/app. The vMCP endpoint and a callback-only bundle (no protected MCP route) are unchanged.AS-1's
limitAS1moved into a shared package,internal/adapter/authserverlimit, which both servers now use. AS-1's behaviour and values are unchanged.Decisions
mcpbroker.AS2.Handler(), used by the identity broker's ID-JAG redemptions): gets the query and body caps but not the public token bucket, so an anonymous flood cannot refuse users' gateway calls. Identity broker RPC contract and transport #2560 deletes this path; whether the broker gets its own budget over the network is decided there.threat-model.mdalready has the "Anonymous traffic at the embedded AS-2" bullet from docs(agent-identity): record AS-1 in-process calls, AS-2's anonymous routes, and distinct issuers #2773, which matches this.authserverlimitunit test proves it.API compatibility
Not a wire API change. The new
429and414responses come from the embedded ToolHive OAuth routes, not the versioned gRPC or HTTP/SSE API. No major or feature changes.Testing
TestLimitAndCaps,TestEmbeddedAuthServerRoutesAreRateLimited(sign-in flood leaves token serving and vMCP unlimited; token flood),TestEmbeddedAuthServerRoutesRefuseAnOversizedQuery,TestAS2InProcessHandlerIsCappedButNotPublicRateLimited,TestCallbackOnlyBundleIsNotRateLimited, plus mounted-route probes in mecak8s and mecated.Capsremoved from AS-2, public bucket on AS-2, limiter on vMCP.task test:race: passes except three tests that fail locally for sandbox reasons in packages this PR doesn't touch (TestMecatedCLICompositionValidatesMicroVMDefaultAfterReadiness, unix socket bind;TestRunInDirUsesDescriptorAndPassesArgumentsOpaquely, no bash;TestRepositoryGuestAuthenticationRejectsCompetingConnectorBeforeDisclosure, timing).task lintstops on a pre-existing gosec finding inenvironment/microvm/launch_ownership_darwin.go.task site:buildpasses. Offline demo shows tool call, permission ask and approval, and result.