Skip to content

fix(security): remove allow-same-origin from MCP Apps sandbox iframes#1064

Open
zeroasterisk wants to merge 2 commits intogoogle:mainfrom
zeroasterisk:fix/mcp-apps-sandbox-security
Open

fix(security): remove allow-same-origin from MCP Apps sandbox iframes#1064
zeroasterisk wants to merge 2 commits intogoogle:mainfrom
zeroasterisk:fix/mcp-apps-sandbox-security

Conversation

@zeroasterisk
Copy link
Copy Markdown
Collaborator

Summary

Fixes a security discrepancy between the MCP Apps guide/spec and the Lit sample implementation. Found during review of PR #1062.

Problem

The Lit sample (mcp-apps-component.ts) and shared sandbox proxy (sandbox.ts) included allow-same-origin in iframe sandbox attributes, violating:

  1. The A2UI guide: states the inner iframe "MUST NOT include allow-same-origin"
  2. The MCP Apps spec (SEP-1865): mandates iframe sandboxing without same-origin access
  3. The MCP Apps SDK docs: example uses sandbox: "allow-scripts" only

The Angular sample (mcp-app.ts) already correctly used sandbox: 'allow-scripts'.

Changes

File Before After
mcp-apps-component.ts (outer iframe) sandbox="allow-scripts allow-forms allow-popups allow-modals allow-same-origin" No sandbox attribute (guide says don't sandbox the proxy)
mcp-apps-component.ts (sendSandboxResourceReady) sandbox: "allow-scripts allow-forms allow-popups allow-modals allow-same-origin" sandbox: "allow-scripts"
sandbox.ts (inner iframe default) allow-scripts allow-same-origin allow-forms allow-scripts

Minimal change: 2 files, 1 commit.

Verification

  • Confirmed against MPC Apps spec (SEP-1865)
  • Confirmed against AppBridge SDK docs — example uses sandbox: "allow-scripts"
  • Angular sample already follows this pattern correctly

Related

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request restricts the sandbox permissions for MCP app iframes by removing several flags, including allow-same-origin, to improve security. Feedback suggests that while removing allow-same-origin is appropriate, other functional flags such as allow-forms, allow-popups, and allow-modals should be retained to ensure basic application features like form submissions and popups continue to work.

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 google#1062.
@zeroasterisk zeroasterisk force-pushed the fix/mcp-apps-sandbox-security branch from 508231a to 7fedb1b Compare April 5, 2026 03:37
@zeroasterisk zeroasterisk requested a review from dmandar April 7, 2026 01:46
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

1 participant