Repository navigation
Description
♻️ Reproduction Steps
- An MCP server (the untrusted party this policy exists for) sends an
ui/open-linkrequest to the host withurlset to"/\evil.com"— a forward slash, a single backslash, thenevil.com. - The host calls
denyDangerousSchemes("/\evil.com")frompackages/mcp-apps-renderer/src/session.ts. - Observe the returned value, and what
window.openis 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
copilotkit-outpost-bot commentedon Oct 5, 2026
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:
denyDangerousSchemesinpackages/mcp-apps-renderer/src/session.tsaccepts any string matching/^(\/|\.\/|\.\.\/)/, resolves it withnew URL(url, window.location.href), and returnsparsed.hrefwithout a subsequent same-origin check. The WHATWG URL normalization behavior you describe (backslash-to-slash in special-scheme URLs turning/\evil.cominto 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 viaparsed.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 beforenew URLis called.The issue tracker reference already in the codebase for a related policy gap is
https://github.com/CopilotKit/CopilotKit/issues/5930(visible inpackages/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 👎
fix(mcp-apps-renderer): refuse open-links that resolve off-origin
fix(mcp-apps-renderer): refuse open-links that resolve off-origin (Co…