fix(security): remove allow-same-origin from MCP Apps sandbox iframes#1064
Open
zeroasterisk wants to merge 2 commits intogoogle:mainfrom
Open
fix(security): remove allow-same-origin from MCP Apps sandbox iframes#1064zeroasterisk wants to merge 2 commits intogoogle:mainfrom
zeroasterisk wants to merge 2 commits intogoogle:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
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.
samples/client/lit/custom-components-example/ui/custom-components/mcp-apps-component.ts
Outdated
Show resolved
Hide resolved
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.
508231a to
7fedb1b
Compare
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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) includedallow-same-originin iframe sandbox attributes, violating:allow-same-origin"sandbox: "allow-scripts"onlyThe Angular sample (
mcp-app.ts) already correctly usedsandbox: 'allow-scripts'.Changes
mcp-apps-component.ts(outer iframe)sandbox="allow-scripts allow-forms allow-popups allow-modals allow-same-origin"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-formsallow-scriptsMinimal change: 2 files, 1 commit.
Verification
sandbox: "allow-scripts"Related