AI Engineer
Standard browser sandboxing forces platforms to choose between credential theft and broken local storage, compelling AI hosts to adopt nested iframes that break apps contacting undeclared domains.
AI-assisted summary of Why MCP and ChatGPT Apps Use Double Iframes — Frédéric Barthelet, Alpic — original source. Check the original for full context.
Source published:
Key ideas
- ChatGPT and Claude isolate third-party Model Context Protocol (MCP) apps using a nested double iframe architecture inherited from Facebook's original app marketplace. (3:31)
- Direct single-iframe approaches fail due to browser security boundaries: standard `srcdoc` inherits the host's strict CSP, relaxing the CSP risks session token theft, and sandboxing with `allow-same-origin` causes a classic sandbox escape. (5:29)
- The production pattern uses unique per-app subdomains on an untrusted proxy domain (such as `openaiusercontent.com`) to serve an identical, lightweight script loader that renders the app's HTML into an inner `srcdoc` frame with its own CSP meta tag. (12:03)
- Alpic introduced Skybridge, an open-source development framework featuring a real-time CSP inspector to prevent common ChatGPT App Store submission rejections caused by undeclared outbound network domains. (15:55)
Detailed notes
## Background Published on YouTube by AI Engineer on June 15, 2026, this talk features Frédéric Barthelet, CTO and co-founder of Alpic. According to the description, Barthelet explains why inspecting ChatGPT during MCP app rendering reveals an iframe nested inside another iframe, systematically ruling out simpler sandboxing techniques and presenting Skybridge's CSP inspector tool.
## TL;DR Frédéric Barthelet investigates why AI hosts like ChatGPT and Claude rely on a nested double iframe architecture to execute third-party Model Context Protocol (MCP) view applications. Walking through simpler approaches—including raw `srcdoc`, relaxed parent CSPs, opaque sandboxing, and direct external sourcing—he illustrates how each either exposes sensitive host storage tokens or strips necessary client-side persistence APIs. To resolve this, platforms adopt a pattern pioneered by Facebook's app marketplace: an outer frame served from a dedicated, per-app subdomain hosts a static loader, which mounts an inner `srcdoc` iframe restricted by its own `<meta>` CSP tag. Because this architecture strictly blocks undeclared network calls, Barthelet demonstrates Skybridge, an open-source development tool with a live CSP inspector designed to prevent deployment errors and store rejections.
## Atmosphere & style The presentation carries the pragmatic, analytical tone of an engineering deep dive, feeling like an over-the-shoulder exploration through browser DevTools. Barthelet balances rigorous security logic with relatable developer nostalgia, comparing modern MCP security hurdles to historic CORS growing pains and early Facebook iframe architectures. The mood shifts smoothly from an architectural post-mortem into a hands-on live coding demonstration, wrapping up with an engaging, community-focused raffle for attendees.
## Bulletin - [03:31](https://www.youtube.com/watch?v=c-2eEv2ou7Y&t=211s) ChatGPT and Claude isolate third-party Model Context Protocol (MCP) apps using a nested double iframe architecture inherited from Facebook's original app marketplace. - [05:29](https://www.youtube.com/watch?v=c-2eEv2ou7Y&t=329s) Direct single-iframe approaches fail due to browser security boundaries: standard `srcdoc` inherits the host's strict CSP, relaxing the CSP risks session token theft, and sandboxing with `allow-same-origin` causes a classic sandbox escape. - [12:03](https://www.youtube.com/watch?v=c-2eEv2ou7Y&t=723s) The production pattern uses unique per-app subdomains on an untrusted proxy domain (such as `openaiusercontent.com`) to serve an identical, lightweight script loader that renders the app's HTML into an inner `srcdoc` frame with its own CSP meta tag. - [15:55](https://www.youtube.com/watch?v=c-2eEv2ou7Y&t=955s) Alpic introduced Skybridge, an open-source development framework featuring a real-time CSP inspector to prevent common ChatGPT App Store submission rejections caused by undeclared outbound network domains.
## Key takeaways - [00:15](https://www.youtube.com/watch?v=c-2eEv2ou7Y&t=15s) MCP apps and ChatGPT extensions represent a new commercial distribution surface combining conversational agent discovery with traditional app store listings. - [02:02](https://www.youtube.com/watch?v=c-2eEv2ou7Y&t=122s) MCP views are packaged HTML, CSS, and JavaScript bundles that are declared upfront during the initial `tools/list` handshake and rendered conditionally following tool executions. - [03:31](https://www.youtube.com/watch?v=c-2eEv2ou7Y&t=211s) Inspecting ChatGPT during MCP app execution reveals a nested double iframe pattern, rather than a single sandboxed frame. - [05:29](https://www.youtube.com/watch?v=c-2eEv2ou7Y&t=329s) Rendering an app via a top-level `srcdoc` iframe fails because it inherits ChatGPT's parent origin and strict CSP requiring cryptographic nonces on all scripts. - [05:29](https://www.youtube.com/watch?v=c-2eEv2ou7Y&t=329s) Relaxing ChatGPT's host CSP to run third-party scripts would grant untrusted apps read access to parent session tokens, cookies, and local storage. - [08:22](https://www.youtube.com/watch?v=c-2eEv2ou7Y&t=502s) Applying standard iframe sandboxing enforces an opaque null origin, which prevents apps from using origin-indexed storage like `localStorage`, `IndexedDB`, and cookies. - [08:22](https://www.youtube.com/watch?v=c-2eEv2ou7Y&t=502s) Adding `allow-same-origin` to a sandboxed iframe that shares the parent origin triggers a classic sandbox escape vulnerability back into the host's DOM and storage. - [08:22](https://www.youtube.com/watch?v=c-2eEv2ou7Y&t=502s) Directly loading third-party endpoints via an iframe `src` attribute is unworkable because the host would need an unbounded, continuously changing whitelist in its CSP `frame-src` directive. - [10:42](https://www.youtube.com/watch?v=c-2eEv2ou7Y&t=642s) Dynamically proxying and serving raw third-party HTML directly from a platform-owned domain introduces severe operational overhead and legal liability for arbitrary code. - [12:03](https://www.youtube.com/watch?v=c-2eEv2ou7Y&t=723s) The double iframe architecture solves origin sharing by hosting a static script loader on isolated subdomains (such as `app-id.openaiusercontent.com`) that injects view HTML into an inner `srcdoc` frame. - [12:03](https://www.youtube.com/watch?v=c-2eEv2ou7Y&t=723s) Using distinct subdomains for the outer frame prevents cross-app storage collisions, isolating `localStorage` and `IndexedDB` between different installed apps. - [12:03](https://www.youtube.com/watch?v=c-2eEv2ou7Y&t=723s) The nested iframe pattern mirrors the isolation technique Facebook originally engineered for its third-party app marketplace. - [14:00](https://www.youtube.com/watch?v=c-2eEv2ou7Y&t=840s) Every external domain an MCP app contacts (scripts, images, API calls) must be pre-declared in its manifest metadata to be written into the inner frame's CSP `<meta>` tag. - [14:00](https://www.youtube.com/watch?v=c-2eEv2ou7Y&t=840s) A key source of ChatGPT app store rejections was developer mode historically bypassing CSP enforcement, masking undeclared domain failures until production deployment. - [15:55](https://www.youtube.com/watch?v=c-2eEv2ou7Y&t=955s) Skybridge provides an open-source development suite with end-to-end typing, platform polyfills, and a live CSP inspector that diffs runtime network requests against declared manifest domains.
## Detailed walkthrough ### [00:15](https://www.youtube.com/watch?v=c-2eEv2ou7Y&t=15s) Introducing MCP Apps and the New UI Surface Area
Frédéric Barthelet introduces himself as the CTO and co-founder of Alpic, an MCP hosting platform, setting the stage for an architectural deep dive into how ChatGPT and Model Context Protocol (MCP) clients isolate third-party applications. Building on preceding talks by Liat and Ido, Barthelet emphasizes that MCP and ChatGPT apps represent an entirely new commercial surface area. This emerging distribution model combines two primary channels: store discoverability (such as the ChatGPT App Store or Claude connectors) and conversational discovery, where an agent dynamically pulls a relevant connector into an ongoing chat to provide extra context and trigger contextual actions.
The primary leap forward is moving conversational AI beyond plain text into interactive user interfaces. Rather than relying solely on generated conversational prose, conversational agents can now render rich client-side UI supplied directly by an MCP server or synthesized via generative UI. Barthelet traces the lineage of this capability from early community experiments with MCP UI (created by Liat and Ido), to OpenAI’s release of an App SDK in October of the prior year, to the standardized, multi-client specification known as the official MCP app extension.
> “That's a new surface area for your business to expose product and services with new acquisition channel that has two main criteria.” — Frédéric Barthelet
[02:02](https://www.youtube.com/watch?v=c-2eEv2ou7Y&t=122s) How Views and Tool Calls Work Under the Hood
To understand why isolation is so tricky, Barthelet walks through the lifecycle of UI rendering in MCP. In MCP terminology, these embedded visual components are called "views." A view is never launched in a vacuum; it is always rendered as the direct consequence of a tool call. When an MCP server registers its available tools, it can attach metadata specifying that a tool's output is best visualized through a dedicated view. If the host client supports the app extension, it intercepts the tool execution and uses the designated view to display the response.
Architecturally, views are standard web artifacts: packaged HTML documents bundling JavaScript and CSS. They are discovered ahead of time during the initial `tools/list` handshake when the conversational host first connects to the MCP server. Each tool that supports an interface advertises the exact assets required to render it, allowing the host either to pre-cache the bundle or fetch it on demand at runtime. When invoked, the conversational client mounts an inline frame into the chat feed and feeds dynamic tool results straight into the document context.
> “Views are simple HTML document. You can include JS and CSS inside. Nothing new under the sun here.” — Frédéric Barthelet
- **Lifecycle trigger:** Views are explicitly paired with specific tool calls via server metadata rather than spawned arbitrarily. - **Discovery timing:** UI resources are declared upfront during the initial `tools/list` exchange between the agent host and the MCP server. - **Dynamic data flow:** The host creates the frame and injects the live tool execution results into the rendering context.
[03:31](https://www.youtube.com/watch?v=c-2eEv2ou7Y&t=211s) The Double Iframe Surprise and ChatGPT's Baseline CSP
Curious about how OpenAI safely renders arbitrary untrusted web code directly inside conversational threads, Barthelet opened the browser developer tools on ChatGPT while an MCP app was active. Rather than finding a conventional single frame, he discovered a nested hierarchy: an iframe embedded inside an outer iframe. This unexpected "inception" pattern prompted him to investigate why standard web sandboxing techniques fell short and why client developers settled on this specific nesting architecture. While using ChatGPT as the running example, he notes that identical security constraints and implementations apply to Claude.
Before considering third-party code, one must look at ChatGPT's existing browser security baseline, governed by Content Security Policy (CSP) HTTP response headers. When loading ChatGPT, the server instructs the browser on what it may fetch, run, and embed. Two directives are particularly critical for third-party views: 1. `script-src`, which defines which scripts can execute in the browser context. 2. `frame-src`, which restricts which domains are permitted to serve iframes inside the parent page.
> “I was a bit surprised and I was met with not so much expectation about having a double iFrame, having an iFrame nested in inside another iFrame.” — Frédéric Barthelet
[05:29](https://www.youtube.com/watch?v=c-2eEv2ou7Y&t=329s) The Flaws of a Single Iframe with srcdoc and Relaxed CSP
The most intuitive implementation for rendering an MCP view is an `<iframe>` configured with the `srcdoc` attribute. Because the host already downloads the view's HTML bundle from the MCP server, passing the raw markup directly into `srcdoc` avoids making a redundant network request. However, Barthelet points out a critical limitation: an iframe populated via `srcdoc` inherits the parent document's origin by default, meaning it also inherits ChatGPT's strict CSP. ChatGPT protects its core application by enforcing a `script-src` policy that requires every script element to carry a unique, per-request cryptographic nonce generated ahead of time. Because arbitrary third-party application bundles lack this pre-generated nonce, their JavaScript is blocked completely by the browser engine.
As a thought experiment, Barthelet considers what happens if OpenAI were to relax ChatGPT's CSP to allow external, arbitrary scripts to run. While this would permit the app's JavaScript to execute, it introduces a severe security flaw: because the `srcdoc` frame shares the parent origin, any script running inside the embedded view shares full access to ChatGPT's origin-indexed storage. A malicious or compromised third-party app could read the user's ChatGPT session tokens, cookies, and `localStorage` keys, and silently transmit them to an external server.
> “I would not suggest doing that into production, just an experimental thought here.” — Frédéric Barthelet
```mermaid flowchart TD accTitle: Progression of single iframe failure modes accDescr: Diagram showing why direct srcdoc, relaxed CSP, sandbox, and allow-same-origin all fail to isolate third-party views.
subgraph DirectSrcDoc["Attempt 1: srcdoc Attribute"] A["Inject view HTML into iframe srcdoc"] --> B["Inherits parent ChatGPT origin & CSP"] B --> C["Blocked by script-src nonce requirement"] end
subgraph RelaxedCSP["Attempt 2: Relax Parent CSP"] D["Allow arbitrary script execution"] --> E["Same origin as ChatGPT parent DOM"] E --> F["App script can steal localStorage & cookies"] end
subgraph SandboxedFrame["Attempt 3 & 4: Sandboxing Trade-offs"] G["Add sandbox attribute"] --> H["Assigns opaque null origin"] H --> I["Breaks localStorage, IndexedDB & cookies"] I --> J["Add allow-same-origin to restore storage"] J --> K["Classic sandbox escape: restores full parent access"] end
C -.-> D F -.-> G ```
[08:22](https://www.youtube.com/watch?v=c-2eEv2ou7Y&t=502s) Sandboxing, Opaque Origins, and the Dead End of Direct src
To block origin sharing while still using inline document injection, the next logical step is adding the `sandbox` attribute to the iframe. Sandboxing forces the iframe into an opaque or "null" origin, severing its relationship with the parent DOM and preventing untrusted scripts from reading ChatGPT's cookies or session state. However, Barthelet explains that this creates an equally unacceptable trade-off: all standard web persistence mechanisms—such as `localStorage`, `indexedDB`, and cookies—are indexed strictly by origin. Under an opaque null origin, an app cannot persist any client-side state between interactions.
If a developer attempts to restore storage access by appending `allow-same-origin` to the sandbox attribute, the iframe is re-bound to the parent document's origin. This triggers the classic web sandbox escape vulnerability: the untrusted child frame regains full programmatic access to ChatGPT's DOM, authentication tokens, and storage, landing right back at square one.
Finally, Barthelet evaluates abandoning `srcdoc` in favor of pointing the iframe's `src` attribute directly to an external endpoint hosted by the app developer (for example, `https://myapp.com/view`). While this would assign the view its own distinct third-party origin and preserve local storage capabilities, it collapses on the host side. ChatGPT's CSP uses the `frame-src` directive to whitelist allowed frame origins. For an open marketplace, OpenAI would have to maintain and dynamically update an unbounded list of external developer domains in its production CSP header every time a new app or connector is published.
> “And the only way to actually provide an origin to a sandboxed iFrame is to put allow same origin, which is an additional attribute that brings back the exact same origin as the parent back into the iFrame and you're back to square one where you have an iFrame with exactly the right condition to escape its sandboxing and access parent DOM, access parent local storage, access parent cookies.” — Frédéric Barthelet
- **Opaque origin penalty:** Sandboxing an iframe with `sandbox` assigns a null origin, disabling `localStorage`, `indexedDB`, and cookie storage for the embedded view. - **The sandbox escape:** Combining `sandbox` with `allow-same-origin` on a document that shares the parent origin completely dismantles the security boundary. - **The `frame-src` bottleneck:** Relying on direct external endpoints via `src="https://..."` would force AI hosts to maintain an infinite, constantly changing whitelist of external domains in their core CSP headers.
[10:42](https://www.youtube.com/watch?v=c-2eEv2ou7Y&t=642s) The Proxy Domain Dilemma and Infrastructure Limits
Attempting to allow every arbitrary third-party domain at full scale is completely unworkable from a security perspective. Instead, a host platform can introduce a single proxy domain under its own control—such as `openaiusercontent.com`, which OpenAI uses specifically to expose untrusted user-generated content outside its primary web properties. By referencing this dedicated domain inside the host's Content Security Policy (CSP) `frame-src` directive, the browser will allow iframes pointing to it without compromising the primary application origin. Under this setup, a server hosted on the user-content domain fetches the raw HTML resources directly from the external Model Context Protocol (MCP) server and dynamically renders them, using a dynamic subdomain prefix as the routing key to distinguish between specific applications.
However, dynamically serving arbitrary third-party code through a platform-owned domain introduces severe operational and liability liabilities. The host platform effectively builds an infrastructure pipeline dedicated to hosting external user interfaces from every developer submitting to their store. As Frédéric Barthelet highlights, this places the host in a dangerous position: “Which is not a very good position to be into because once again, you will be responsible for code that you don't know what it's doing and you will be exposing it on your own domain.” Furthermore, smaller hosts outside of OpenAI or Anthropic rarely possess the engineering and infrastructure resources required to orchestrate this level of complex, dynamic server-side content distribution.
- `openaiusercontent.com` serves as OpenAI’s designated secondary domain to display untrusted content safely off the primary `chatgpt.com` origin. - Routing keys embedded in subdomains (for example, `app-id.openaiusercontent.com`) direct incoming traffic to the appropriate MCP application assets. - Dynamically proxying and hosting external HTML forces the platform owner to accept direct liability for rendering unknown, untrusted code.
---
[12:03](https://www.youtube.com/watch?v=c-2eEv2ou7Y&t=723s) The Double Iframe Architecture and Facebook's Legacy
To resolve the hosting dilemma, hosts turn to the double iframe pattern. Instead of generating distinct HTML files dynamically on the server for each app, the outer iframe serves a single, universal, and lightweight script loader to every client. This script retrieves the target application's resources and instantiates an inner nested iframe populated via the `srcdoc` attribute. Because the outer iframe resides on an external sandbox domain separate from ChatGPT, the inner `srcdoc` frame inherits the sandbox domain's origin rather than the parent ChatGPT application, eliminating the sandbox escape and data-leak vulnerabilities inherent in top-level `srcdoc` usage.
To prevent cross-application interference, the outer loader script is served across unique per-app subdomains. While every subdomain serves the exact same static JavaScript loader, the distinct origins ensure that browser APIs requiring origin indexing—such as `localStorage`, `IndexedDB`, and cookies—cannot collide or be accessed across applications. For instance, application `ABC123` cannot inspect the stored credentials or cache of application `ABC456`. Content Security Policies are then enforced inside the view by injecting an appropriate `<meta http-equiv="Content-Security-Policy">` tag into the inner frame based on the app's MCP specification metadata. Barthelet notes that this architecture is not novel, but rather a battle-tested pattern borrowed from early web application platforms: “This is the actual solution that I implemented into production. And it's not a new solution. It's been around for a long time and actually the first time this solution was implemented was back in Facebook days when they released their app marketplace, which is exactly the same problem that you have to run and render third-party UI inside the context of your own application.”
```mermaid flowchart TD accTitle: Double Iframe Isolation Architecture accDescr: Diagram showing ChatGPT embedding an outer iframe on a dedicated subdomain, which in turn embeds an inner srcdoc iframe with its own CSP meta tag.
subgraph ParentHost ["Host Application (chatgpt.com)"] HostApp["ChatGPT Main DOM"] end
subgraph OuterSandbox ["Outer Iframe Sandbox"] OuterFrame["app-id.openaiusercontent.com<br/>(Lightweight Static Script Loader)"] end
subgraph InnerContent ["Inner Iframe Sandbox"] InnerFrame["Nested srcdoc Iframe<br/>(MCP App HTML + UI)"] CSPMeta["Meta Tag CSP<br/>(Enforces Declared Domains)"] end
HostApp -->|"Embeds via frame-src"| OuterFrame OuterFrame -->|"Loads static script & renders"| InnerFrame InnerFrame --- CSPMeta ```
- **Outer Iframe:** Serves an identical, static JavaScript loader across isolated subdomains, drastically minimizing backend hosting infrastructure. - **Origin Indexing Isolation:** Distinct subdomains prevent separate apps from reading each other's `localStorage`, session storage, or cookie jars. - **Inner Iframe:** Receives app markup via `srcdoc` and applies client-side CSP restrictions using HTML `<meta>` tags. - **Historical Precedent:** Facebook popularized this exact nested iframe sandboxing structure when launching its original third-party App Marketplace.
---
[14:00](https://www.youtube.com/watch?v=c-2eEv2ou7Y&t=840s) CSP Declarations, Metadata, and Developer Pain
For application developers building on top of the MCP app specification, the double iframe architecture imposes strict configuration requirements. Because the inner iframe renders under an explicit CSP `<meta>` tag, any external domain the application communicates with or loads assets from must be declared ahead of time inside the application's MCP metadata. When the host environment constructs the nested iframe, it rewrites these metadata declarations into the appropriate CSP policy directives. If an app makes an outbound network call to an external API to retrieve data, that endpoint must be explicitly declared in the `connect-src` array; similarly, third-party libraries, tracking pixels, or visual assets require explicit entries under `script-src` and `img-src`.
Dealing with rigid browser security directives evoked painful memories for Barthelet, who recalled his early days as a software engineer: “As a new developer in the space, I was experiencing a trouble getting cross-origin resource security right calls. I had trouble getting it right. CSP reminded me of those ugly day of not getting right the first time with calls.” Historically, developer ergonomics around MCP testing were severely flawed. In ChatGPT's developer mode, CSP enforcement was historically stripped out entirely during local testing. As a result, developers would successfully test an application locally, only to discover upon deploying to production or submitting to the app store that their views failed to render and their network requests were blocked due to undeclared CSP origins.
- Developers must declare all external endpoints across directives like `connect-src`, `script-src`, `img-src`, and `frame-src` within their MCP app manifest. - Failing to declare a domain causes the browser's CSP engine inside the inner iframe to reject network requests and script executions immediately. - Previous iterations of ChatGPT's developer mode completely bypassed CSP rules, creating a false sense of security that led to immediate breakages in production environments.
---
[15:55](https://www.youtube.com/watch?v=c-2eEv2ou7Y&t=955s) Skybridge and the Live CSP Inspector Demo
To eliminate the friction of CSP mismatches and platform inconsistencies, Alpic built Skybridge, an open-source development framework designed as a superset of the official MCP app SDKs. Skybridge provides end-to-end type safety between MCP backend servers and frontend widgets, bundles polyfills for host-specific platform quirks across Claude and ChatGPT, and introduces dedicated local inspection tooling. Barthelet switched to his screen to demonstrate Skybridge’s local development environment, running a starter Magic 8-Ball sample application featuring an MCP tool that selects from 25 predefined answers and a reactive view component that renders the question and response.
``` +------------------------------------------------------------------+ | Skybridge CSP Inspector | | | | [Status: MISMATCH DETECTED] | | | | Declared Domains (Metadata): | | - None | | | | Live Network Activity: | | - [X] https://api.iplocation.net/ <-- MISSING IN METADATA! | | | | Action: Add "api.iplocation.net" to connect-src in mcp.json | +------------------------------------------------------------------+ ```
Opening the Skybridge dev tool in the browser, Barthelet highlighted its built-in CSP Inspector. The tool monitors all network requests initiated by the active view in real time and diffs them against the domains declared in the app’s metadata. While the initial Magic 8-Ball view showed all green checks, Barthelet edited the source code live to fetch the user’s IP location from an external API. The inspector immediately flagged the undeclared domain in red as a missing CSP entry. After he added the API domain to the metadata configuration file and refreshed, the status returned to green. Barthelet explained the practical necessity of this tool: “So, neat little tool. There are a lot of other features that are packed inside Skybridge, but that's one of them that we made sure to be available to builders because we've seen a lot of rejection coming from ChatGPT app store submission because of missing CSP and app not working in production because of missing CSP domains.” He concluded his presentation by inviting the audience to scan on-screen QR codes for his slide deck and GitHub repository, holding an impromptu raffle of ski goggles for attendees who starred the Skybridge repo.
- **Skybridge Framework:** Open-source tooling from Alpic delivering TypeScript safety, host polyfills (Claude/ChatGPT), and local emulation. - **Magic 8-Ball Demo:** A starter MCP application demonstrating split execution between an answer-generation tool (25 possible outcomes) and an interactive canvas view. - **CSP Inspector:** Intercepts real-time runtime network calls and flags any discrepancies against declared MCP manifest domains before store submission. - **Community Incentive:** A live giveaway of ski goggles was held for audience members starring the Skybridge repository at the close of the session.
## Mentioned Frédéric Barthelet, Alpic, Skybridge, ChatGPT, OpenAI, Model Context Protocol (MCP), Anthropic, Claude, Facebook, Liat, Ido, openaiusercontent.com
## Video description Inspect ChatGPT's DOM while an MCP app is rendering and you find an iframe nested inside another iframe. Frédéric Barthelet traces why each simpler approach fails: `srcdoc` shares the parent origin so ChatGPT's CSP blocks all third party scripts; relaxing that CSP lets any app read ChatGPT's localStorage and cookies; adding `sandbox` removes origin indexed storage; adding `allow-same-origin` to restore it is the classic sandbox escape. The double iframe is what remains after ruling all of that out.
The outer iframe serves one lightweight script from a controlled subdomain (different subdomain per app to prevent cross app storage collisions), which loads the actual app HTML via `srcdoc` into the inner frame — the same pattern Facebook first shipped for their app marketplace. The practical implication: every external domain your view touches must be declared in your MCP app metadata or the submission gets rejected. Barthelet demos Skybridge's CSP inspector, which diffs declared domains against actual network calls live in dev.
Speaker info: - https://x.com/bartheletf - https://www.linkedin.com/in/frederic-barthelet/ - https://github.com/fredericbarthelet
---
Watch along with the corrected transcript, summary, timestamps and resources on this talk's official AIE page: https://ai.engineer/talks/c-2eEv2ou7Y-why-mcp-and-chatgpt-apps-use-double-iframes-frederic-barthelet-alpic
Join our upcoming AI Engineer conferences (see https://ai.engineer landing page):
- AIEi Shanghai, November 5–6 — the first for meeting top Chinese labs and engineers - AIE CODE in SF, November 10–12 — the top AI Coding conference returns - AIEi Sydney, December 7–8 — the first AIEi run alongside NeurIPS 2026 in Sydney
---
[Source](https://www.youtube.com/watch?v=c-2eEv2ou7Y)