When an MCP client connects to a protected server, the server tells the client which URLs to fetch and which authorisation page to open in a browser, so a malicious or hijacked server can hand the client a URL designed to run code, execute script or phish the user. This guide explains where those server-controlled URLs enter the MCP authorisation flow, how unsafe handling turns them into command execution, cross-site scripting or credential phishing, and the client, host and registry controls that block them. It is written for MCP client and host developers, AI platform security teams and anyone approving remote MCP servers for use. It is based on the MCP specification revision 2026-07-28 and its Security Best Practices page, checked in November 2026; the specification changes often, so confirm against the current revision. The OAuth flow itself is covered in the MCP Authorisation Specification Guide and the credential choice in API Keys vs OAuth for MCP Servers; this page is about the URLs.
Key takeaways
- Every discovery URL is attacker-controllable. The
resource_metadataURL, theauthorization_serverslist and the endpoints in authorisation server metadata all come from, or are pointed to by, the MCP server the client is connecting to. - The browser launch is the dangerous sink. The specification's Security Best Practices say clients MUST allow only
https://(andhttp://for loopback during development) and MUST NOT open URLs throughcmd.exe,shor PowerShell. - CVE-2025-6514 is the reference case. mcp-remote versions 0.0.5 to 0.1.15 passed a server-supplied
authorization_endpointto an OS launcher, leading to OS command injection (CWE-78, CVSS 9.6); 0.1.16 fixed it. - Validation is layered. Scheme allowlisting, strict URL parsing, issuer and resource identity checks, SSRF filtering and non-shell opening each stop a different variant; no single check is enough.
- Show the user where they are going. Display the authorisation server host before opening the browser, and treat a server whose authorisation host is unexpected as untrusted until approved.
How MCP authorisation discovery works
Under the 2026-07-28 revision, authorisation is optional and applies to HTTP-based transports; stdio servers take credentials from the environment instead. When authorisation is in use, the client discovers everything it needs from the server it is trying to reach:
- 401 challenge: the client sends an unauthenticated request and receives
401 Unauthorizedwith aWWW-Authenticate: Bearerheader that should carry aresource_metadataURL (RFC 9728 Section 5.1) and may carry ascope. - Protected resource metadata: the client fetches that URL, or falls back to
/.well-known/oauth-protected-resourceat the endpoint path and then at the root. The document MUST list at least one entry inauthorization_servers. RFC 9728 Section 3.3 requires the returnedresourcevalue to be identical to the resource identifier the client used, or the data MUST NOT be used. - Authorisation server metadata: the client builds well-known URLs from the chosen issuer and tries, in order,
/.well-known/oauth-authorization-server(RFC 8414) and/.well-known/openid-configuration(OpenID Connect Discovery), with path insertion for issuers that have paths. Theissuerin the document MUST be identical to the issuer used to build the URL; otherwise the client MUST NOT use the metadata. - Registration: the client obtains a client ID through a Client ID Metadata Document, pre-registration or Dynamic Client Registration (deprecated in this revision).
- Browser launch: the client builds an authorisation URL from
authorization_endpoint, adds PKCE (S256), theresourceparameter and scopes, records the expected issuer, and opens the URL in the user's browser. - Callback and token: the client validates
isson the response (RFC 9207), then sends the code and verifier totoken_endpoint.
Steps 1 to 5 all involve URLs that the client did not choose. Steps 1 to 3 are network fetches by the client; step 5 hands a URL to the operating system or a browser API.
How URL injection occurs
URL injection happens when a client treats a value from discovery as a safe web address and passes it on without checking what it really is. The table lists each server-influenced value and what goes wrong without validation.
| Value | Source | Client action | Failure without validation |
|---|---|---|---|
resource_metadata | MCP server WWW-Authenticate header | HTTP fetch | SSRF to internal services or cloud metadata endpoints |
authorization_servers | Protected resource metadata | Builds well-known URLs, HTTP fetch | SSRF; selection of an attacker's authorisation server |
issuer | Authorisation server metadata | Recorded and later compared | Mix-up if the document is accepted from a different host |
authorization_endpoint | Authorisation server metadata | Opened in browser | Non-web scheme executed, shell metacharacters interpreted, or phishing page shown |
token_endpoint, registration_endpoint | Authorisation server metadata | HTTP POST | SSRF with state-changing requests; code or secret sent to the wrong host |
error_uri, error_description | Authorisation response | Displayed or linked | Phishing text or links; the spec forbids acting on them when iss does not match |
The Security Best Practices page names two client-side injection paths for the authorisation URL itself:
- Script URL injection: a server supplies a
javascript:URL as the authorisation endpoint and the client passes it towindow.open()or a similar API, giving script execution inside the client application. - Command injection via shell execution: a server supplies a URL containing shell metacharacters and the client opens it through
cmd.exe, PowerShell or a shell script, which interprets part of the string as further commands.
Delivery does not need a compromised well-known server. The best practices page and the JFrog analysis of CVE-2025-6514 both describe the precondition as connecting to an untrusted or malicious MCP server; JFrog adds plain HTTP connections on a local network, where an attacker can tamper with responses. A user persuaded to add a server from a link, a shared configuration file or an unvetted directory listing is enough. This is the same pattern as ATT&CK T1204.001 Malicious Link combined with T1203 Exploitation for Client Execution.
Impact: phishing and command execution
| Outcome | Mechanism | Typical result |
|---|---|---|
| OS command execution | Authorisation URL passed to a shell-based launcher | Code runs with the user's privileges on the developer workstation |
| Client-side script execution | javascript: or data: URL opened inside a web or Electron-style client | Session theft; in proxy architectures, theft of the local proxy token and spawning of stdio commands |
| Credential phishing | Valid https:// URL to a look-alike sign-in page | User enters corporate credentials or approves consent for an attacker client |
| Internal network access | Discovery URLs pointing at private or link-local addresses | Cloud instance credentials or internal service data reflected to the attacker |
CVE-2025-6514 illustrates the first row. According to the GitHub advisory GHSA-6xpm-ggf7-wc3p, mcp-remote, a proxy that lets local clients reach remote MCP servers, was exposed to OS command injection when connecting to untrusted servers, through crafted input in the authorization_endpoint URL. JFrog's analysis explains that the value was passed to the open npm package; on Windows that package launches through PowerShell, allowing full command execution, while on macOS and Linux it uses open or xdg-open without a shell, which JFrog says limited impact to launching executables. Upgrading to 0.1.16 or later is the fix.
The impact is high because MCP clients run on developer and analyst machines that often hold cloud credentials, source code access and tokens for other MCP servers. See the Local MCP Server Security Guide for what sits within reach of a compromised client.
Client-side defences
The specification's Security Best Practices set the baseline. Implement every item, in this order.
- Allowlist schemes: accept only
https://for authorisation URLs, andhttp://only for loopback (localhost,127.0.0.1,::1) behind an explicit development setting. Rejectjavascript:,data:,file:,vbscript:and anything else. Use an allowlist, not a blocklist. - Parse, then rebuild: parse the endpoint with a standards-compliant URL parser, reject parse failures, credentials in the authority, and characters a shell could interpret, then build the final authorisation URL from the parsed components and your own encoded query parameters rather than concatenating strings.
- Open without a shell: never pass the URL through
cmd.exe,shor PowerShell. Use a platform URL-opening API or launch the handler with an argument array and no shell. In Electron and similar desktop frameworks, treat the open-external call as a sink: the Electron security checklist says not to useshell.openExternalwith untrusted content, so validate before calling it. - Enforce identity checks: reject protected resource metadata whose
resourcedoes not match, and authorisation server metadata whoseissuerdoes not match the URL it came from. Verify TLS certificates (RFC 9728 Section 7.3). Record the issuer before redirecting and validateisson return. - Constrain discovery fetches: require HTTPS, block private, loopback and link-local ranges (
10.0.0.0/8,172.16.0.0/12,192.168.0.0/16,127.0.0.0/8,169.254.0.0/16,fc00::/7,fe80::/10), validate every redirect hop, and pin DNS between check and use. Use a maintained library rather than hand-written IP parsing. Server-side clients should route discovery through an egress proxy. See the SSRF Prevention Guide. - Show a pre-launch confirmation: before opening the browser, show the user the MCP server name, the authorisation server host (not just a friendly name) and the scopes requested, and require a click. Flag when the authorisation host is on a different registrable domain from the MCP server, or has never been seen before.
- Harden web-based clients: apply a Content Security Policy with
script-src 'self'anddefault-src 'self'so an injected script URL cannot run, and isolate any local proxy token from the renderer. - Log and keep dependencies current: log rejected URLs with the server identity, and track OAuth and MCP proxy libraries such as mcp-remote in your software inventory so advisories reach you.
Choosing an opening approach
| Approach | Risk | When to use |
|---|---|---|
| Shell command with URL string | Metacharacters interpreted as commands | Never, per the specification |
| Handler launched with argument array, no shell | Non-web schemes can still launch registered handlers | Acceptable only after scheme allowlisting |
| Platform or framework URL-open API | Same scheme-handler risk if unvalidated | Preferred for desktop clients, after validation |
| Embedded web view | Script injection into the client context; users cannot see the real address bar | Avoid for authorisation; use the system browser |
| Device or out-of-band flow showing the URL for the user to open | Phishing still possible, no local execution | Headless and server-side clients |
Server and registry defences
Client fixes stop exploitation; server, host and registry controls reduce exposure to untrusted servers in the first place.
- Approved server lists: organisations deploying MCP clients should restrict which remote servers can be added, through managed configuration or an MCP gateway, and record the expected authorisation server host for each. See Agent Gateway vs MCP Gateway.
- Registry vetting: directories and internal catalogues should fetch each listed server's protected resource and authorisation server metadata, reject listings whose endpoints use non-HTTPS schemes or unexpected hosts, and re-check on a schedule because metadata can change after approval.
- Server operators: serve all metadata and authorisation endpoints over HTTPS, keep
authorization_serversto the hosts you control or contract, and emitissin authorisation responses (the specification signals this will move from SHOULD to MUST). - Authorisation servers: follow the specification's open redirection rules: validate exact pre-registered redirect URIs, clearly display the redirect URI hostname, warn on
localhost-only redirect URIs, and apply SSRF protection when fetching Client ID Metadata Documents. - Configuration hygiene: one-click server installation must show the exact command or URL being added and require approval, as the best practices page requires for local server configuration.
Detection and response
Most of this activity happens on endpoints, so detection combines client telemetry with endpoint and network signals.
- Client logs: alert on rejected authorisation URLs (bad scheme, parse failure, issuer or resource mismatch), and on a known server whose authorisation host changes.
- Endpoint telemetry: watch for MCP client, Node.js or proxy processes spawning
cmd.exe,powershell.exe,shor unexpected executables, especially just after an OAuth prompt. - Network: flag client hosts requesting link-local metadata addresses or internal ranges during MCP connection set-up, and sign-in pages on newly registered domains reached from MCP prompts.
- Software inventory: query for vulnerable mcp-remote versions (0.0.5 to 0.1.15) and other OAuth helper packages across developer machines and CI images.
If a client may have opened a malicious authorisation URL: isolate the workstation, capture the client configuration and logs (the server URL, the metadata responses if cached, process trees), remove the server from configuration, upgrade the client, and rotate tokens and credentials reachable from that machine, including tokens for other MCP servers. If the user entered credentials on a phishing page, reset them, revoke sessions and review consent grants. See the MCP Tool Poisoning Detection guide for related client-side detections.
Metrics
- Client coverage: share of MCP clients in use that implement scheme allowlisting and non-shell opening (from vendor statements or testing).
- Vulnerable package count: endpoints with known-vulnerable MCP proxy or OAuth helper versions; target zero.
- Unapproved servers: remote MCP servers configured outside the approved list.
- Rejected URL events per month, each reviewed.
- Time to patch MCP client advisories across developer machines.
Framework mapping
| Framework | Reference | How it applies |
|---|---|---|
| MITRE ATT&CK | T1204.001 Malicious Link; T1203 Exploitation for Client Execution; T1059 Command and Scripting Interpreter | Malicious server URL leading to client exploitation and command execution |
| CWE | CWE-78 OS Command Injection | The weakness class assigned to CVE-2025-6514 |
| NIST SP 800-53 Rev 5 | SI-10 Information Input Validation; SA-11 Developer Testing and Evaluation; CM-7 Least Functionality; SI-4 System Monitoring | Validating server-supplied URLs, testing clients, restricting launch paths, monitoring process spawns |
| NIST CSF 2.0 | PR.PS-06; DE.CM-09 | Secure development of MCP clients; monitoring of endpoint software behaviour |
Common failure patterns
- Trusting metadata because it arrived over the protocol: clients treat
authorization_endpointas configuration rather than untrusted input. - Convenience launchers: using a cross-platform "open this URL" helper that shells out on one platform, so the bug appears only on Windows and escapes testing elsewhere.
- Blocklisting schemes: rejecting
javascript:but notfile:, custom protocol handlers or case and encoding variants. - Skipping identity checks: not comparing the metadata
issuerorresourcewith the URL used, which lets one host speak for another. - Silent browser launch: opening the authorisation page with no indication of the host, so users cannot spot a look-alike domain.
- Forgotten transitive packages: an MCP proxy pulled in by a configuration snippet stays on a vulnerable version long after the advisory.
Practitioner checklist
- Allowlist
https://(and loopbackhttp://in development only) for every authorisation URL. - Remove every shell-based URL opening path; use a non-shell API after validation.
- Parse and rebuild authorisation URLs rather than concatenating server strings.
- Enforce RFC 9728
resourcematching, RFC 8414issuermatching and RFC 9207issvalidation. - Apply SSRF controls to all discovery fetches and redirect hops.
- Show the authorisation host and scopes and require confirmation before opening the browser.
- Restrict remote MCP servers to an approved list with expected authorisation hosts.
- Inventory and patch MCP proxy and OAuth helper packages, including mcp-remote 0.1.16 or later.
- Alert on MCP client processes spawning shells and on rejected authorisation URLs.
Standards and references
- Model Context Protocol: Security Best Practices (2026-07-28)
- Model Context Protocol: Authorization Server Discovery (2026-07-28)
- Model Context Protocol: Authorization Security Considerations (2026-07-28)
- IETF: RFC 9728 OAuth 2.0 Protected Resource Metadata
- IETF: RFC 8414 OAuth 2.0 Authorization Server Metadata
- GitHub Advisory Database: CVE-2025-6514 mcp-remote OS command injection
- JFrog: Critical RCE Vulnerability in mcp-remote, CVE-2025-6514
- Electron: Security checklist
Related NHI Mgmt Group resources: MCP Authorisation Specification Guide · MCP Security Best Practices Explained · Remote MCP Server Hardening Guide · MCP Client Support Tracker · API Keys vs OAuth for MCP Servers