File tree Expand file tree Collapse file tree
src/ModelContextProtocol/Auth Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -60,11 +60,19 @@ public static AuthorizationConfig UseHttpListener(
6060
6161 /// <summary>
6262 /// Default implementation to open a URL in the default browser.
63+ /// Only allows http and https URLs to be opened for security reasons.
6364 /// </summary>
6465 private static Task DefaultOpenBrowser ( string url )
6566 {
6667 try
6768 {
69+ // Validate that the URL is using http or https protocol
70+ if ( ! Uri . TryCreate ( url , UriKind . Absolute , out var uri ) ||
71+ ( uri . Scheme != "http" && uri . Scheme != "https" ) )
72+ {
73+ return Task . FromException ( new ArgumentException ( "Only HTTP or HTTPS URLs can be opened." , nameof ( url ) ) ) ;
74+ }
75+
6876 if ( RuntimeInformation . IsOSPlatform ( OSPlatform . Windows ) )
6977 {
7078 // On Windows, use the built-in Process.Start for URLs
You can’t perform that action at this time.
0 commit comments