Skip to content

Commit 7fedb1b

Browse files
zeroasteriskZaf
authored andcommitted
fix(security): remove allow-same-origin from MCP Apps sandbox iframes
The Lit sample and shared sandbox proxy included allow-same-origin in iframe sandbox attributes, violating the MCP Apps guide/spec: - Lit outer iframe: removed sandbox attribute entirely (guide says don't sandbox the proxy iframe) - Lit sendSandboxResourceReady: allow-scripts only (was allow-scripts allow-forms allow-popups allow-modals allow-same-origin) - Shared sandbox.ts inner iframe default: allow-scripts only (was allow-scripts allow-same-origin allow-forms) The Angular sample already correctly used sandbox: 'allow-scripts'. Confirmed against MCP Apps spec (SEP-1865) and AppBridge SDK docs. Fixes security discrepancy found by Gemini Code Assist review on #1062.
1 parent 29f58e8 commit 7fedb1b

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

samples/client/lit/custom-components-example/ui/custom-components/mcp-apps-component.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ export class McpApp extends Root {
7676
<iframe
7777
id="mcp-sandbox"
7878
referrerpolicy="origin"
79-
sandbox="allow-scripts allow-forms allow-popups allow-modals allow-same-origin"
8079
></iframe>
8180
</div>
8281
`;
@@ -176,7 +175,7 @@ export class McpApp extends Root {
176175
// 4. Send the Inner HTML UI resource to the sandbox to spin up the actual app.
177176
await this.bridge.sendSandboxResourceReady({
178177
html: this.htmlContent,
179-
sandbox: "allow-scripts allow-forms allow-popups allow-modals allow-same-origin"
178+
sandbox: "allow-scripts"
180179
});
181180
}
182181

samples/client/shared/mcp_apps_inner_iframe/sandbox.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ if (!disableSelfTest) {
6363
// iframe on a separate origin. It creates an inner iframe for untrusted HTML content.
6464
const inner = document.createElement("iframe");
6565
inner.style.cssText = "width:100%; height:100%; border:none;";
66-
inner.setAttribute("sandbox", "allow-scripts allow-same-origin allow-forms");
66+
inner.setAttribute("sandbox", "allow-scripts");
6767
document.body.appendChild(inner);
6868

6969
const RESOURCE_READY_NOTIFICATION: McpUiSandboxResourceReadyNotification["method"] =

0 commit comments

Comments
 (0)