Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

fix(conversations): give the widget proxy frame its own origin

oxoxDev50715a72e570
diff --git a/app/src/features/conversations/tools/mcpUi/McpAppFrame.tsx b/app/src/features/conversations/tools/mcpUi/McpAppFrame.tsx
index 4898a1de0c..37a1564ea1 100644
--- a/app/src/features/conversations/tools/mcpUi/McpAppFrame.tsx
+++ b/app/src/features/conversations/tools/mcpUi/McpAppFrame.tsx
@@ -10,7 +10,7 @@ import { requestComposerPrefill } from './composerPrefill';
import { QrHandoff } from './LinkActions';
import { McpAppBridge } from './mcpAppBridge';
import type { McpUiPresentation, McpUiResource } from './types';
-import { isWindowsHost, widgetProxyUrl } from './widgetUrl';
+import { isWindowsHost, PROXY_FRAME_SANDBOX, widgetProxyUrl } from './widgetUrl';
const log = debug('mcp-ui:frame');
@@ -121,7 +121,7 @@ export function McpAppFrame({ presentation }: { presentation: McpUiPresentation
ref={frameRef}
src={src}
title={presentation.title ?? t('conversations.mcpUi.widgetTitle')}
- sandbox="allow-scripts allow-forms"
+ sandbox={PROXY_FRAME_SANDBOX}
referrerPolicy="no-referrer"
allow=""
className={
diff --git a/app/src/features/conversations/tools/mcpUi/widgetUrl.test.ts b/app/src/features/conversations/tools/mcpUi/widgetUrl.test.ts
index 789e4dc839..6f63c862d6 100644
--- a/app/src/features/conversations/tools/mcpUi/widgetUrl.test.ts
+++ b/app/src/features/conversations/tools/mcpUi/widgetUrl.test.ts
@@ -1,6 +1,6 @@
import { describe, expect, it } from 'vitest';
-import { widgetProxyUrl } from './widgetUrl';
+import { PROXY_FRAME_SANDBOX, widgetProxyUrl } from './widgetUrl';
describe('widgetProxyUrl', () => {
it('uses the platform origin and carries the declared origins', () => {
@@ -18,3 +18,13 @@ describe('widgetProxyUrl', () => {
);
});
});
+
+describe('PROXY_FRAME_SANDBOX', () => {
+ it('gives the proxy an origin a widget can post to, and nothing else', () => {
+ expect(PROXY_FRAME_SANDBOX.split(' ').sort()).toEqual([
+ 'allow-forms',
+ 'allow-same-origin',
+ 'allow-scripts',
+ ]);
+ });
+});
diff --git a/app/src/features/conversations/tools/mcpUi/widgetUrl.ts b/app/src/features/conversations/tools/mcpUi/widgetUrl.ts
index 9556f04de9..5b957b43ee 100644
--- a/app/src/features/conversations/tools/mcpUi/widgetUrl.ts
+++ b/app/src/features/conversations/tools/mcpUi/widgetUrl.ts
@@ -1,5 +1,12 @@
import type { McpUiResource } from './types';
+/**
+ * Sandbox for the proxy frame. The proxy keeps its own `ohwidget:` origin so a
+ * widget can address it with `postMessage`; the widget itself runs in the
+ * proxy's inner frame without `allow-same-origin`.
+ */
+export const PROXY_FRAME_SANDBOX = 'allow-scripts allow-same-origin allow-forms';
+
/** The sandbox proxy URL on the widget origin, carrying the declared CSP. */
export function widgetProxyUrl(csp: McpUiResource['csp'] | undefined, windows: boolean): string {
const base = windows ? 'http://ohwidget.localhost/proxy' : 'ohwidget://localhost/proxy';