COOP and COEP Explained: Cross-Origin Isolation
On this page
Learning Objective
Explain what Cross-Origin-Opener-Policy severs and what Cross-Origin-Embedder-Policy requires, describe why both are needed together to reach the crossOriginIsolated state, and identify which powerful APIs depend on it.
Concept Explanation
Spectre, disclosed in January 2018, showed that speculative execution lets code read memory it should not be able to reach within the same address space. For browsers this was existential: if an attacker's script shares a process with another origin's data, the language-level Same-Origin Policy is not a sufficient boundary. The immediate response was to disable or coarsen high-resolution timers and to disable SharedArrayBuffer, since a shared memory buffer plus a worker gives an attacker an arbitrarily precise clock. The durable response was Site Isolation plus a way for a document to prove that nothing untrusted shares its process, and COOP and COEP are that proof.
Cross-Origin-Opener-Policy governs the relationship between a document and the windows that opened it or that it opens. By default, a page opened via window.open retains a reference to its opener and the two share a browsing context group, which means they may share a process and can reach each other through a small set of cross-origin-permitted properties. COOP: same-origin severs this: the document is placed in a fresh browsing context group, window.opener is null, and cross-window references in both directions are cut. The value same-origin-allow-popups keeps references to popups the document itself opens while still isolating it from whoever opened it, which is the practical choice for a page that runs OAuth or payment popups.
Cross-Origin-Embedder-Policy addresses the other direction: what the document pulls in. With COEP: require-corp, every cross-origin subresource must explicitly opt in to being embedded, either by carrying a Cross-Origin-Resource-Policy header allowing it or by being fetched through CORS. Anything that does not opt in simply fails to load. The alternative value credentialless is more deployable: cross-origin no-cors requests are sent without credentials, so the resource cannot return per-user data and therefore does not need to opt in, which avoids having to chase every third-party asset provider for a header change.
Cross-origin isolation requires both headers together, and the reason is that they close complementary halves of the same hole. COOP guarantees nothing untrusted holds a window reference into your context group. COEP guarantees nothing untrusted was loaded into your document without consent. Only when both hold can the browser be confident that the document's process contains no cross-origin data an attacker could reach speculatively, and it then sets self.crossOriginIsolated to true and unlocks the restricted capabilities.
What you gain is concrete: SharedArrayBuffer, which is required by WebAssembly threads and therefore by any serious compute-heavy web application; high-resolution performance.now timers rather than the deliberately coarsened ones; and performance.measureUserAgentSpecificMemory. Chrome required cross-origin isolation for SharedArrayBuffer on desktop from Chrome 92 in 2021. What you pay is deployment effort: every third-party embed, analytics tag, font, image, and iframe in the document must either opt in or be loaded credentiallessly, which is why the standard approach is to deploy COEP in report-only mode first and work through the resulting inventory.
| Header and value | What it does | When to use |
|---|---|---|
| COOP: unsafe-none | The default; opener relationships preserved | Legacy behavior only |
| COOP: same-origin-allow-popups | Isolates from the opener, keeps popups it opens | Pages that run OAuth or payment popups |
| COOP: same-origin | Full browsing context group isolation | Required for cross-origin isolation |
| COEP: unsafe-none | The default; any subresource may load | Legacy behavior only |
| COEP: credentialless | No-cors subresources are fetched without credentials | Deployable isolation without third-party cooperation |
| COEP: require-corp | Every cross-origin subresource must opt in | Strictest isolation; needs CORP or CORS on everything |
Worked Example: Reaching the crossOriginIsolated State
The sequence below is the realistic deployment path: measure with report-only, fix what breaks, then enforce and verify from the page itself.
# STEP 1 - measure. Neither header enforces anything yet.
Cross-Origin-Opener-Policy-Report-Only: same-origin; report-to="coop"
Cross-Origin-Embedder-Policy-Report-Only: require-corp; report-to="coep"
Reporting-Endpoints: coop="/reports/coop", coep="/reports/coep"
# Reports name every subresource that would break and every window
# relationship that would be severed. Triage that inventory first.
# STEP 2 - enforce, once the report streams are quiet.
Cross-Origin-Opener-Policy: same-origin
Cross-Origin-Embedder-Policy: require-corp
# STEP 3 - verify from the page.
if (self.crossOriginIsolated) {
const sab = new SharedArrayBuffer(1024); // now permitted
// performance.now() also returns high-resolution values again
} else {
// Fall back: a single header is not enough, BOTH must be in force.
}
# Every cross-origin subresource must now opt in, for example:
# Cross-Origin-Resource-Policy: cross-origin (on the CDN's response)
# ...or be fetched with CORS:
# <img src="https://cdn.example.com/logo.png" crossorigin>
# If third parties will not add CORP, use the more deployable value.
# Cross-origin no-cors subresources are then fetched WITHOUT credentials,
# so they cannot return per-user data and need no opt-in:
Cross-Origin-Embedder-Policy: credentiallessReal-World Examples
- Browser vendors disabled SharedArrayBuffer across the board following the January 2018 Spectre disclosure, because shared memory combined with a worker provides an attacker with a timer of effectively arbitrary precision, which is the key ingredient in a practical speculative execution side channel; Chrome restored it on desktop from Chrome 92 in 2021 but only for documents that have achieved cross-origin isolation through COOP and COEP together.
- COEP: credentialless was added specifically because require-corp proved undeployable for many sites: reaching isolation required persuading every third-party image host, font provider, analytics vendor, and embedded widget to add a Cross-Origin-Resource-Policy header, which is not something a site operator can do unilaterally, so the credentialless variant trades the opt-in requirement for stripping credentials from no-cors subresource requests.
Review Questions & Answers
Because Spectre does not violate the Same-Origin Policy in the language sense at all. It reads physical memory in the process through a speculative execution side channel, entirely below the level at which the policy is expressed and enforced. No change to the policy's rules can prevent code from measuring cache timing. The only durable answer is to ensure that data from other origins is not in the same address space, which is what Site Isolation plus COOP and COEP accomplish.
It places the document in a fresh browsing context group, so window.opener becomes null and cross-window references are cut in both directions between the document and any window that opened it or that it opens. That matters because a retained window reference can force two documents to share a process and provides a channel between them; severing it is what lets the browser guarantee that no untrusted document holds a handle into the isolated document's context group.
require-corp needs every cross-origin subresource to opt in with a CORP header or be fetched with CORS, which requires cooperation from every third party a site embeds and is often impossible to obtain. credentialless instead strips credentials from cross-origin no-cors requests, so those resources cannot return per-user data and no opt-in is needed. The tradeoff is that any third-party resource which genuinely depended on cookies, such as a personalized image, will no longer receive them and will behave as if the user were anonymous.
COEP is missing or not being applied. Cross-origin isolation requires both headers simultaneously, because each closes a different half of the hole: COOP ensures nothing untrusted holds a window reference into the context group, and COEP ensures nothing untrusted was loaded into the document. Until both are in force the browser leaves self.crossOriginIsolated false and keeps the restricted capabilities locked, and checking that property is the fastest way to confirm.