fix(auth): prevent javascript url injection in oauth endpoints#841
fix(auth): prevent javascript url injection in oauth endpoints#841arjunkmrm wants to merge 2 commits intomodelcontextprotocol:mainfrom
Conversation
|
Is there a situation where an authorization server could be behind a custom protocol? For example raycast uses |
|
@paoloricciuti another option is to selectively disallow certain schemes like |
Yeah exactly my thought...also technically nothing prevents the MCP server to specify a authorization url that lead to a page with malicious JS even if the protocol was https |
|
I guess if it specifies a url of a page containing malicious JS, the risk is relatively contained because the page context is of different origin. Opposed to, for example, for example: |
pcarleton
left a comment
There was a problem hiding this comment.
hey thanks for this.
I'd rather we validate the metadata on fetch, and reject it there than have to chase every time its used
|
Updated |
|
thinking about it some more, i think it'd be better to do it when parsing via zod (channeling parse, don't validate ), let's follow up on this PR: https://github.com/modelcontextprotocol/typescript-sdk/pull/877/files |
Added URL scheme validation to OAuth endpoints to prevent JavaScript URL injection attacks. Only
http:andhttps:schemes are now allowed in OAuth authorization server metadata.Motivation and Context
Malicious authorization servers could return OAuth endpoints with dangerous URL schemes (like
javascript:,data:,file:) that could lead to XSS/RCE attacks when processed by OAuth clients.The attack flow:
{"authorization_endpoint": "javascript:alert('XSS')"}How Has This Been Tested?
httporhttpsscheme as authorization endpointsTypes of changes
Checklist