Does this issue occur when all extensions are disabled?: Yes
VSCode Insiders
Version: 1.109.0-insider
Commit: f60f946
Date: 2026-01-21T05:54:27.524Z
Electron: 39.2.7
ElectronBuildId: 13098910
Chromium: 142.0.7444.235
Node.js: 22.21.1
V8: 14.2.231.21-electron.0
OS: Darwin arm64 24.5.0
The Bug
VS Code patches addEventListener in MCP App iframes and tries to read event.source.origin to filter messages. However, reading event.source.origin on a cross-origin source throws a SecurityError:
Uncaught SecurityError: Failed to read a named property 'origin' from 'Window':
Blocked a frame with origin "vscode-webview://..." from accessing a cross-origin frame.
Source: chatMcpAppModel.ts#L313
The Problem
The patched code does something like:
if (event.source.origin === document.location.origin) { ... }
But reading event.source.origin on a cross-origin frame throws! The fix should either:
- Wrap this in a try/catch block
- Use
event.origin instead of event.source.origin
Why This Matters
MCP Apps may need to embed cross-origin iframes and communicate with them via postMessage. This is a common pattern for:
- Embedding third-party widgets
- Loading content from CDNs
- Communicating with sandboxed content
Reproduction Steps
See comprehensive reproduction at https://github.com/JReinhold/vscode-iframe-reproduction/tree/main
1. Clone and Install
git clone git@github.com:JReinhold/vscode-iframe-reproduction.git
cd vscode-iframe-reproduction
npm install
2. Start the MCP Server
The server will start on http://localhost:3000/mcp
3. Open in VS Code Insiders
Open this folder in VS Code Insiders. The .vscode/mcp.json file is already configured to connect to the local MCP server.
4. Call the MCP Tool
In VS Code's GitHub Copilot Chat, ask:
Call the show-example tool with message "test"
5. Trigger the Bug
- The MCP App loads with a nested iframe from
http://localhost:3000
- Click the red "Send Message to Parent (triggers bug)" button in the nested iframe
- Observe the
SecurityError appear in the error box and in DevTools console
cc Connor Peet (@connor4312), as discussed in the MCP UI Discord
Does this issue occur when all extensions are disabled?: Yes
VSCode Insiders
Version: 1.109.0-insider
Commit: f60f946
Date: 2026-01-21T05:54:27.524Z
Electron: 39.2.7
ElectronBuildId: 13098910
Chromium: 142.0.7444.235
Node.js: 22.21.1
V8: 14.2.231.21-electron.0
OS: Darwin arm64 24.5.0
The Bug
VS Code patches
addEventListenerin MCP App iframes and tries to readevent.source.originto filter messages. However, readingevent.source.originon a cross-origin source throws aSecurityError:Source: chatMcpAppModel.ts#L313
The Problem
The patched code does something like:
But reading
event.source.originon a cross-origin frame throws! The fix should either:event.origininstead ofevent.source.originWhy This Matters
MCP Apps may need to embed cross-origin iframes and communicate with them via
postMessage. This is a common pattern for:Reproduction Steps
See comprehensive reproduction at https://github.com/JReinhold/vscode-iframe-reproduction/tree/main
1. Clone and Install
git clone git@github.com:JReinhold/vscode-iframe-reproduction.git cd vscode-iframe-reproduction npm install2. Start the MCP Server
The server will start on
http://localhost:3000/mcp3. Open in VS Code Insiders
Open this folder in VS Code Insiders. The
.vscode/mcp.jsonfile is already configured to connect to the local MCP server.4. Call the MCP Tool
In VS Code's GitHub Copilot Chat, ask:
5. Trigger the Bug
http://localhost:3000SecurityErrorappear in the error box and in DevTools consolecc Connor Peet (@connor4312), as discussed in the MCP UI Discord