You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(client): add CSP query parameter support for HTTP header-based CSP
Add support for passing CSP configuration via URL query parameter (?csp=<json>)
to the sandbox proxy. This enables proxy servers to set Content-Security-Policy
via HTTP headers (tamper-proof) rather than relying on meta tags or postMessage.
Changes:
- AppFrame.tsx: Build sandbox URL with CSP query param before loading iframe
- SandboxConfig.csp: Updated docs explaining query-param + postMessage fallback
- using-a-proxy.md: Added CSP Query Parameter section with server-side example
- Updated architecture diagram to show CSP flow through server
The CSP is still sent via postMessage as a fallback for proxies that don't
support the query parameter approach.
See: modelcontextprotocol/ext-apps#234
Claude-Generated-By: Claude Code (cli/claude-opus-4-5=100%)
Claude-Steers: 2
Claude-Permission-Prompts: 0
Claude-Escapes: 0
3.**SandboxtheIframe**: ForexternalURLs, thenestediframeshouldbesandboxedwith`allow-scripts allow-same-origin`. ForrawHTMLmode, theinneriframedoes**not**useasandboxattribute—thisisintentionalbecause`document.write()`requiressame-originaccesstotheiframe's document. Security for raw HTML is enforced by the outer iframe'ssandbox (controlledbythehost) andthedouble-iframeisolationarchitecture.
80
83
4.**Forward`postMessage`Events**: ToallowcommunicationbetweenthehostapplicationandtheembeddedexternalURL, theproxyneedstoforward`message`eventsbetween`window.parent`andtheiframe's `contentWindow`. For security, it'scriticaltouseaspecific`targetOrigin`insteadof`*`in`postMessage`callswheneverpossible. The`targetOrigin`formessagestotheiframeshouldbetheexternalURL's origin; Messages to the parent will default to `*`.
The CSP is also sent via `postMessage` after the sandbox loads as a fallback for proxies that don't support the query parameter approach. However, HTTP header-based CSP is strongly recommended as it's tamper-proof.
0 commit comments