-
Notifications
You must be signed in to change notification settings - Fork 2.8k
feat(mcp-apps): add Permission Policy support for sandbox iframes #6947
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -15,6 +15,7 @@ import { | |||||||||||||||||||||||||||||
| ToolResult, | ||||||||||||||||||||||||||||||
| ToolCancelled, | ||||||||||||||||||||||||||||||
| CspMetadata, | ||||||||||||||||||||||||||||||
| PermissionsMetadata, | ||||||||||||||||||||||||||||||
| McpMethodParams, | ||||||||||||||||||||||||||||||
| McpMethodResponse, | ||||||||||||||||||||||||||||||
| } from './types'; | ||||||||||||||||||||||||||||||
|
|
@@ -40,6 +41,7 @@ interface McpAppRendererProps { | |||||||||||||||||||||||||||||
| interface ResourceData { | ||||||||||||||||||||||||||||||
| html: string | null; | ||||||||||||||||||||||||||||||
| csp: CspMetadata | null; | ||||||||||||||||||||||||||||||
| permissions: PermissionsMetadata | null; | ||||||||||||||||||||||||||||||
| prefersBorder: boolean; | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
|
|
@@ -58,6 +60,7 @@ export default function McpAppRenderer({ | |||||||||||||||||||||||||||||
| const [resource, setResource] = useState<ResourceData>({ | ||||||||||||||||||||||||||||||
| html: cachedHtml || null, | ||||||||||||||||||||||||||||||
| csp: null, | ||||||||||||||||||||||||||||||
| permissions: null, | ||||||||||||||||||||||||||||||
| prefersBorder: true, | ||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||
| const [error, setError] = useState<string | null>(null); | ||||||||||||||||||||||||||||||
|
|
@@ -82,13 +85,14 @@ export default function McpAppRenderer({ | |||||||||||||||||||||||||||||
| if (response.data) { | ||||||||||||||||||||||||||||||
| const content = response.data; | ||||||||||||||||||||||||||||||
| const meta = content._meta as | ||||||||||||||||||||||||||||||
| | { ui?: { csp?: CspMetadata; prefersBorder?: boolean } } | ||||||||||||||||||||||||||||||
| | { ui?: { csp?: CspMetadata; permissions?: PermissionsMetadata; prefersBorder?: boolean } } | ||||||||||||||||||||||||||||||
| | undefined; | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| if (content.text !== cachedHtml) { | ||||||||||||||||||||||||||||||
| setResource({ | ||||||||||||||||||||||||||||||
| html: content.text, | ||||||||||||||||||||||||||||||
| csp: meta?.ui?.csp || null, | ||||||||||||||||||||||||||||||
| permissions: meta?.ui?.permissions || null, | ||||||||||||||||||||||||||||||
| prefersBorder: meta?.ui?.prefersBorder ?? true, | ||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
|
Comment on lines
91
to
98
|
||||||||||||||||||||||||||||||
| if (content.text !== cachedHtml) { | |
| setResource({ | |
| html: content.text, | |
| csp: meta?.ui?.csp || null, | |
| permissions: meta?.ui?.permissions || null, | |
| prefersBorder: meta?.ui?.prefersBorder ?? true, | |
| }); | |
| } | |
| setResource({ | |
| html: content.text, | |
| csp: meta?.ui?.csp || null, | |
| permissions: meta?.ui?.permissions || null, | |
| prefersBorder: meta?.ui?.prefersBorder ?? true, | |
| }); |
Copilot
AI
Feb 4, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
permissions is passed into the sandbox bridge, but the outer proxy iframe rendered by this component never sets an allow attribute; Permission Policy is intersected across ancestor iframes, so camera/mic/geolocation/clipboard-write will likely stay blocked when the proxy URL is cross-origin (e.g., goosed baseUrl). Consider also setting allow on the React iframe based on resource.permissions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The permissions checks rely on truthiness (e.g.
permissions.camera), so a malformed metadata value like'true'would unintentionally enable the feature; please validate each permission is exactlytruebefore adding it to the allow list.