-
Notifications
You must be signed in to change notification settings - Fork 1.4k
confused deputy fix in example + supporting sdk changes #648
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
061739d
to
bdea6dd
Compare
@@ -218,6 +219,26 @@ async def error_response( | |||
) | |||
|
|||
try: | |||
# Check if client has already consented | |||
has_consent = await self.provider.has_client_consent(client) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
todo: check client_consent_required
before doing this
src/mcp/server/auth/provider.py
Outdated
@@ -174,6 +174,27 @@ async def authorize( | |||
""" | |||
... | |||
|
|||
async def has_client_consent(self, client: OAuthClientInformationFull) -> bool: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
todo: if client_consent_required, these need to be required, but otherwise they should be optional. open to suggestions here. i think a default implementation of return True
means we'd solve for being optional, but not for required.
ede25d3
to
48eb13d
Compare
Motivation and Context
See the confused deputy consideration here:
https://github.com/modelcontextprotocol/modelcontextprotocol/blob/c255349bd98d9dc73f3579c828d195bd09c0bee8/docs/specification/draft/basic/security_best_practices.mdx#21-confused-deputy-problem
In the example, we front the Github API, so we need to put a consent screen for each new client registration, otherwise the Github consent screen will be skipped for new clients, creating a path for token leakage.
Still TODO:
Here's what the consent screen looks like:

How Has This Been Tested?
Tested using inspector to run through auth flow
Breaking Changes
Types of changes
Checklist
Additional context