Complete Page Setup: Tier Definitions, HTTP Headers & Durable Object Wiring
End-to-end wiring from public/index.html, public/app.js, src/headers.ts, public/lib/taint-engine.js, and src/worker.ts: the page mounts sandboxed tier frames or Dedicated Workers, the edge emits per-tier CSP or RFC 9651 Connection-Allowlist headers with Reporting-Endpoints, and TaintedSession tracks object provenance with Proxy, WeakSet, and WeakMap.
<!-- 1. Page HTML Setup (public/index.html) -->
<div class="tier-strip" id="tier-cards"></div>
<div class="sandbox-viewport" id="frame-mount"></div>
<div id="enclave-mount"></div>
<script type="module" src="/app.js"></script>
// 2. Concrete 7-Tier Capability & Header Definitions (public/app.js & src/headers.ts)
const TIERS = [
{ tier: 1, name: "Tier 1: Unrestricted", desc: "Same-origin iframe, zero sandbox, zero CSP.", sandboxAttr: null },
{ tier: 2, name: "Tier 2: Collapsed", desc: 'sandbox="allow-scripts allow-same-origin"', sandboxAttr: "allow-scripts allow-same-origin" },
{ tier: 3, name: "Tier 3: Opaque Frame", desc: 'sandbox="allow-scripts" (no CSP)', sandboxAttr: "allow-scripts" },
{ tier: 4, name: "Tier 4: Opaque + CSP", desc: "sandbox=\"allow-scripts\" + connect-src 'none'", sandboxAttr: "allow-scripts" },
{ tier: 5, name: "Tier 5: Locked Worker", desc: "Dedicated Worker + CSP connect-src 'none'", sandboxAttr: null },
{ tier: 6, name: "Tier 6: Allowlist ()", desc: "Connection-Allowlist: () (no CSP header)", sandboxAttr: "allow-scripts" },
{ tier: 7, name: "Tier 7: Scoped Allowlist", desc: 'Connection-Allowlist: (".../fetch")', sandboxAttr: "allow-scripts" },
];
// src/headers.ts — sandboxHeadersForTier(7, cleanOrigin, runId) & Tier 4/6 contracts:
const tier4Headers = {
"X-Containment-Tier": "4",
"Reporting-Endpoints": `csp-endpoint="${cleanOrigin}/api/report/${runId}"`,
"Content-Security-Policy": "default-src 'none'; script-src 'nonce-...'; connect-src 'none'; img-src 'none'; style-src 'none'; form-action 'none'; base-uri 'none'; report-to csp-endpoint",
};
const tier7Headers = {
"Content-Type": "text/html; charset=utf-8",
"Cache-Control": "no-store",
"X-Containment-Tier": "7",
"Reporting-Endpoints": `ca-endpoint="${cleanOrigin}/api/report/${runId}"`,
"Connection-Allowlist": `("${cleanOrigin}/api/canary/${runId}/fetch"); report-to=ca-endpoint`,
}; // Tier 6 emits Connection-Allowlist: (); report-to=ca-endpoint
// 3. Page Bootstrap, <iframe sandbox> Mount, TaintedSession Proxy & Edge DO Wiring
const iframe = document.createElement("iframe");
iframe.className = "probe-frame";
if (tierDef.sandboxAttr !== null) iframe.setAttribute("sandbox", tierDef.sandboxAttr);
iframe.src = `/sandbox/tier/${tierDef.tier}?runId=${encodeURIComponent(state.runId)}`;
document.getElementById("frame-mount").replaceChildren(iframe);
window.addEventListener("message", (event) => {
if (event.data?.type === "SANDBOX_READY") {
iframe.contentWindow?.postMessage({ type: "RUN_PROBES", secret: SYNTHETIC_SECRET }, "*");
}
});
const { events } = await fetch(`/api/canary/${state.runId}/events`, { cache: "no-store" }).then((r) => r.json());
const session = new TaintedSession(); // WeakSet #taintedObjects + WeakMap #objectMeta + Proxy get() trap
const fetched = session.readUntrusted("fetched_doc", { metadata: { callbackUrl: "https://evil.example/drop", summary: "<p>Edge POP latency steady.</p>" } }, "https://untrusted.example/nested-json-proxy");
const cleanSummary = session.declassify("redacted_json_summary", String(fetched.metadata.summary), STRICT_SUMMARY_DECLASSIFIER);
session.callSink("external_fetch", cleanSummary); // Direct call on fetched.metadata throws TaintSecurityError
Core Plumbing Required Today (Edge Headers & Recursive Proxy Wrapping)
// src/headers.ts — connectionAllowlistHeaders() & sealedEnclaveHeaders()
// Tier 6: Connection-Allowlist: (); report-to=ca-endpoint
// Tier 7: Connection-Allowlist: ("https://origin/api/canary/:runId/fetch"); report-to=ca-endpoint
const enclaveHeaders = {
"Content-Security-Policy": "default-src 'none'; script-src 'nonce-...' 'wasm-unsafe-eval'; connect-src 'none'; form-action 'none'; base-uri 'none'",
"Connection-Allowlist": "(); report-to=csp-endpoint",
"Referrer-Policy": "no-referrer",
};
// public/lib/taint-engine.js — WeakSet + Proxy taint propagation on property reads
#wrapObject(target, source, label) {
const proxy = new Proxy(target, {
get: (obj, prop, receiver) => {
const val = Reflect.get(obj, prop, receiver);
return val !== null && typeof val === "object"
? this.#wrapObject(val, `${source}.${String(prop)}`, `${label}.${String(prop)}`)
: val;
},
});
this.#taintedObjects.add(proxy);
this.#objectMeta.set(proxy, { source, label });
return proxy;
}