Clamp remote source overrides#1372
Open
jlfetter1 wants to merge 2 commits into
Open
Conversation
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.
Summary
Fixes the OAuth source-scope bypass reported in #1371.
This PR treats remote
source_idtool parameters as requests, not authority. For remote MCP callers, source selection is now clamped to the caller's OAuthallowedSources/sourceIdclaims at tool invocation time.Changes
query.source_idto the caller's allowed source set.permission_deniedinstead of returning empty success.source_id=__all__to the caller's allowed sources.get_page.source_idselection for allowed shared/canonical sources.get_page source_id=__all__.thinkgather.searchTakes/searchTakesVectorin Postgres and PGLite implementations.__all__, explicit sharedget_page, unauthorizedget_page, andthinksource scoping.Security framing
The issue maps to CWE-285 Improper Authorization, with related CWE-266 and CWE-20 concerns. It also matches Bishop Fox's LLM testing pattern "Authorization Bypass through User Controlled Parameter." In this case,
source_idis authority-bearing and must be validated server-side against token claims.Verification
Executed locally in the fork worktree:
Result: 19 passed, 0 failed.
Result: passed.
Also live-tested in a downstream OAuth deployment with synthetic canary pages: unauthorized
query.source_idno longer leaked cross-source content,source_id=__all__clamped to allowed sources, explicitget_page source_id=sharedworked, and source-scope audit rows were written.No sensitive data was used in the reproduction or verification.