Skip to content

Conversation

jba
Copy link
Contributor

@jba jba commented Sep 29, 2025

Fix Protected Resource Metadata to prevent URL attacks, as described in the issue.

For #526

Fix Protected Resource Metadata to prevent URL attacks,
as described in the issue.

For modelcontextprotocol#526
Copy link
Contributor

@findleyr findleyr left a comment

Choose a reason for hiding this comment

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

This LGTM (though I have only superficial knowledge of the problem).

However, changes like this should include a test.

Copy link
Collaborator

@rolandshoemaker rolandshoemaker left a comment

Choose a reason for hiding this comment

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

Approved with one documentation comment, should probably also have a test.

return err
}
scheme := strings.ToLower(uu.Scheme)
if scheme == "javascript" || scheme == "data" || scheme == "vbscript" {
Copy link
Collaborator

Choose a reason for hiding this comment

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

My guess is that we can't just blanket block everything except http(s), because it's plausible that some servers may want to authenticate using a custom app protocol, but that is a little worrying, since it's not immediately clear to me that those couldn't similarly be used for attacks.

I see this is what other SDKs have done though, so perhaps this is the best option we have. There should at least be a comment here explaining why we block these particular schemes, and why we cannot just only allow http(s).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I got the list of schemes from https://github.com/modelcontextprotocol/typescript-sdk/pull/877/files#diff-a0fe23c86bd448c6fa4c60fe4d380daa65451fea86a9e760673a5a7c65292e88, line 20. There's no explanation in that PR for where that list comes from. Clearly, they are all suspect, but I don't know if there are other suspect schemes as well. However, the article you cited, https://verialabs.com/blog/from-mcp-to-shell, seems to think that the above PR is sufficient. (See the section called the most impactful fix.}

Copy link
Collaborator

Choose a reason for hiding this comment

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

Seems fine with me. I think we should document that somewhere though.

@findleyr
Copy link
Contributor

Can we land this today? Would be good to include in the next release (planned soon).

@IAmSurajBobade
Copy link
Contributor

@jba I have added tests for your changes in your fork. If you have already added please ignore.

jba#5

@jba jba merged commit fd0dc9d into modelcontextprotocol:main Sep 30, 2025
5 checks passed
@jba
Copy link
Contributor Author

jba commented Sep 30, 2025

I merged this, but the comments should be addressed in a follow up. @samthanawalla

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.

5 participants