Skip to content

Conversation

pcarleton
Copy link
Member

@pcarleton pcarleton commented May 7, 2025

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:

  • make the has_consent functions optional (currently every provider needs to implement them)
  • allow overriding consent handler (currently always uses the default one)
  • consider keeping consent handler abstract in the SDK, and putting example impl into the example directory

Here's what the consent screen looks like:
CleanShot 2025-05-07 at 11 19 05@2x

How Has This Been Tested?

Tested using inspector to run through auth flow

  • w/ consent required
  • w/o consent required

Breaking Changes

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

Additional context

@pcarleton pcarleton mentioned this pull request May 7, 2025
@pcarleton pcarleton force-pushed the pcarleton/auth-confused-deputy branch from 061739d to bdea6dd Compare May 7, 2025 10:13
@@ -218,6 +219,26 @@ async def error_response(
)

try:
# Check if client has already consented
has_consent = await self.provider.has_client_consent(client)
Copy link
Member Author

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

@@ -174,6 +174,27 @@ async def authorize(
"""
...

async def has_client_consent(self, client: OAuthClientInformationFull) -> bool:
Copy link
Member Author

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.

Base automatically changed from ihrpr/auth-example to main May 7, 2025 16:52
@pcarleton pcarleton force-pushed the pcarleton/auth-confused-deputy branch from ede25d3 to 48eb13d Compare May 9, 2025 11:21
@felixweinberger felixweinberger added needs more work Not ready to be merged yet, needs additional changes. needs publish Draft PRs need to be published for team to review labels Sep 5, 2025
Copy link
Contributor

@felixweinberger felixweinberger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @pcarleton just checking whether we're still planning to ship this? Marking it as "needs publish" for now so we can easily filter it from views.

I also assume we might still need some merge conflict resolution here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs more work Not ready to be merged yet, needs additional changes. needs publish Draft PRs need to be published for team to review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants