Skip to content

Security: denyDangerousSchemes resolves a /\\ prefixed open-link to a foreign origin #7632

Closed

Description

@aniruddhaadak80

♻️ Reproduction Steps

  1. An MCP server (the untrusted party this policy exists for) sends an ui/open-link request to the host with url set to "/\evil.com" — a forward slash, a single backslash, then evil.com.
  2. The host calls denyDangerousSchemes("/\evil.com") from packages/mcp-apps-renderer/src/session.ts.
  3. Observe the returned value, and what window.open is then called with.

✅ Expected Behavior

Rule 3 of the policy documents that a path-relative link is "resolved against the host document" and that "a widget can reach a path of the HOST application". So "/\evil.com" must either resolve to a path on the host origin, or be refused — never navigate to a foreign origin.

❌ Actual Behavior

The relative branch accepts any string starting with /, ./ or ../, resolves it against window.location.href, and returns the resolved href without ever checking that the result stayed on the host origin:

if (!/^(\/|\.\/|\.\.\/)/.test(url)) return undefined;
absolute = false;
parsed = new URL(url, window.location.href);
...
return absolute ? url : parsed.href;

Per the WHATWG URL spec, a backslash is normalized to / inside the path of a special-scheme base. That turns the leading /\ into a protocol-relative authority, so the string resolves off-origin:

new URL("/\\evil.com", "http://localhost:3000/").href  ===  "http://evil.com/"

Verified in node. new URL("/\evil.com") without a base throws Invalid URL, so control always reaches the vulnerable relative branch, and the function returns "http://evil.com/". The host then calls:

window.open("http://evil.com/", "_blank", "noopener,noreferrer");

The host application navigates to an origin the MCP server chose. This is not script execution (noopener is set), but it is a deliberate bypass of a documented security boundary in the one policy that is deliberately shared by every frontend (React, Vue and Angular all consume this function), so the reach is fleet-wide.

Screenshots

N/A — URL-policy behaviour; reproducible in a jsdom unit test.

𝌚 CopilotKit Version

[email protected] (main @ 692660299)
└── @copilotkit/mcp-apps-renderer

📄 Logs (Optional)

# denyDangerousSchemes("/\\evil.com")
#   today  -> "http://evil.com/"      (expected: undefined)

Activity

  1. copilotkit-outpost-bot commented on Oct 5, 2026

    @copilotkit-outpost-bot

    Engineering will need to verify and own the fix here — I won't prescribe changes to the policy function itself.

    What I can confirm from the source: denyDangerousSchemes in packages/mcp-apps-renderer/src/session.ts accepts any string matching /^(\/|\.\/|\.\.\/)/ , resolves it with new URL(url, window.location.href), and returns parsed.href without a subsequent same-origin check. The WHATWG URL normalization behavior you describe (backslash-to-slash in special-scheme URLs turning /\evil.com into an authority) is a real property of the spec, and the reproduction in Node is straightforward to verify. The policy comment in that file explicitly states it is "shared by every frontend" and that "no frontend overrides anything," so the scope of any affected surface is as wide as you've described.

    One thing worth flagging to the team alongside this report: the scheme denylist lives in packages/mcp-apps-renderer/src/constants.ts (MCP_OPEN_LINK_BLOCKED_SCHEMES) and is checked via parsed.protocol — that check runs correctly — but it fires after the relative-resolution step, so a same-origin assertion would need to be inserted between resolution and the scheme check, or the regex gate would need to be tightened to reject authority-relative forms before new URL is called.

    The issue tracker reference already in the codebase for a related policy gap is https://github.com/CopilotKit/CopilotKit/issues/5930 (visible in packages/runtime/src/v2/runtime/handlers/shared/mcp-apps-servers.ts); the team may want to track this alongside or separately from that.


    🤖 Generated by CopilotKit AI Support · Documentation


    Was this helpful? React with 👍 or 👎

  2. added 2 commits that reference this issue on Oct 23, 2026
    1abe71d
    4177870
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions