CSPEE: Detecting… Buffer Origin: Separate Worker

Dual-Origin Sandbox Lab · CSP, Sandbox Flags, CSPEE, Connection-Allowlist & MessagePort Bridges

CSP & Iframe Sandbox Studio

Running untrusted HTML, generated code, or third-party widgets inside a browser tab requires separating them from your site's storage and stopping silent network leaks. This studio runs across two real web origins so you can test <iframe sandbox> flags, Content Security Policy (CSP), single vs. double-nested iframes, CSP Embedded Enforcement (CSPEE), Connection-Allowlist, narrowed MessagePort bridges, and four Web Worker setups against a live Cloudflare Durable Object server collector.

Why this matters

Debates over browser sandboxing often rely on guesses about double iframes, <meta> CSP tags, <iframe csp>, and blob: Workers. Even client APIs like sendBeacon() can return true when CSP actually blocked the request—so real containment needs a second origin and a server-side check.

What this opens up

Safe plugin hosts, untrusted HTML previews, and AI-generated UI panels running directly in the browser: choose a faster single cross-origin frame when you control the headers, a double-iframe buffer for uncontrolled third-party content, and a revocable MessagePort that exposes only allowlisted methods.

How the tests work

Pick one of the six presets in Tab 1 (or customize flags and headers), then click Run Active Preset in 14-Vector Harness. The test mounts live frames on a separate companion origin and verifies zero hits on the Durable Object canary, then compares three cross-origin messaging bridges and four Worker setups.

Dual-Origin Setup Main Studio Origin, Separate Buffer Origin & Live Canary Server
Two Separate Web Origins · Zero Shared Storage, Cookies, or DOM
Origin A · Host App

Studio Worker src/worker.ts

csp-iframe-sandbox-studio.kinlan-test.workers.dev
  • Serves the Studio UI, /probe/frame, and locked HTTP Workers
  • Hands out narrowed, revocable MessagePort handles (hawser-bridge.js)
Origin B · Untrusted Buffer

Buffer Companion src/buffer-worker.ts

csp-sandbox-buffer-origin.kinlan-test.workers.dev
  1. /buffer: Serves HTTP CSP + Connection-Allowlist: () in single, double, bridge, or worker mode
  2. /uncontrolled-3p: Omits CSP headers to test Chrome <iframe csp> enforcement
  3. /buffer-worker.js: Runs an isolated cross-origin Web Worker with no access to Host storage
0 CANARY HITS

Sealed Boundary

Reporting-Endpoints -> /reports/:runId

Blocked requests send CSP reports to ContainmentTelemetry while zero traffic reaches /api/canary/*.

>0 CANARY HITS

Confirmed Leak

SQLite DO -> /api/canary/:runId/:vector

Logs the exact leak channel (fetch, image, WebSocket, subframe), HTTP method, origin, and timestamp.

Both origins send Cache-Control: no-cache, X-Content-Type-Options: nosniff, explicit frame-ancestors, and zero X-Frame-Options.

Start Here: 6 Real-World Sandbox Presets

Click any preset to compare single-frame HTTP CSP, double-iframe nesting, <meta> CSP tampering, and <iframe csp>—then run all 14 live leak probes in Tab 2.

  1. Compare single vs. double iframes: Run preset Single Cross-Origin + Connection-Allowlist, then Double-Iframe Buffer, and click Compare Single vs Double Latency in Tab 2.
  2. Test capability narrowing: Open Tab 3 and click Call Disallowed write() and Prototype-Walk constructor Escape to see Hawser block both while the unfiltered proxy leaks.
  3. Contrast Worker storage leaks: Open Tab 4 and click Run All 4 Worker Topologies to see why a same-origin blob: Worker inherits page storage while an opaque or cross-origin Worker blocks it.

Topology & HTML sandbox Flags

Configure framing depth, delivery mechanism, and all 9 HTML sandbox tokens.

Frames: 1
HTML sandbox Attribute Flags (9 flags)
Live Engine Capabilities: iframe.csp: … TrustedTypes: … ReportingObserver: … OPFS: …

HTTP CSP Directives & Isolation Extensions

Compiles directly into live Cloudflare Worker response headers for /probe/frame and /buffer.

Compiled Wire Headers & Iframe Markup

Exact headers emitted by the target Cloudflare Worker and exact embedder attributes.

HTTP Response Headers
Embedder <iframe> Markup
Key terms & further reading
<iframe sandbox> Flags
Nine opt-in tokens on an iframe that lock embedded content into a throwaway origin unless explicitly relaxed (avoid pairing allow-scripts with allow-same-origin on your own origin).
Content Security Policy (CSP Level 3)
An immutable HTTP response header controlling which scripts, nested frames (frame-src), images, and network requests a document or Web Worker may perform.
CSP Embedded Enforcement (CSPEE)
The Chromium-only <iframe csp="..."> attribute that asks an embedded third-party page to agree to a minimum CSP before the browser renders it.
Connection-Allowlist (WICG)
A single deny-by-default HTTP header that blocks outbound connections—including redirects, prefetches, and WebRTC—unless their URL matches an explicit allowlist.
MessagePort Capability Bridge (Hawser)
A private two-way channel transferred into a sandboxed frame that exposes only allowlisted methods, blocks prototype-chain escapes, and revokes access immediately via port.close().
Cloudflare Durable Object Canary
A server-side SQLite state store that records real arriving HTTP/WebSocket requests and CSP violation reports so containment is verified outside the browser.