Skip to main content
Beta: Front-End Checklist is currently in beta. Some issues are still being fixed. Thanks for your patience.

Use COOP, COEP, and CORP for cross-origin isolation when needed

Sensitive or high-capability applications use COOP, COEP, and CORP deliberately, audit third-party embeds, and verify cross-origin isolation in the browser before relying on it.

Utilities
Quick take
Typical fix time 30 min
  • Use `Cross-Origin-Opener-Policy` and `Cross-Origin-Embedder-Policy` together when you need cross-origin isolation
  • Audit every cross-origin script, iframe, image, worker, and font before enforcing COEP
  • Serve embeddable resources with CORS or `Cross-Origin-Resource-Policy` as appropriate
  • Verify `self.crossOriginIsolated === true` before depending on isolated-only features
Why it matters: Cross-origin isolation reduces opener-based attacks and XS-Leak risk, and it is required for powerful browser features such as SharedArrayBuffer in modern browsers. It also breaks integrations if deployed carelessly, so it needs a deliberate rollout rather than a copy-pasted header block.

Rule Details

Cross-origin isolation is not a blanket requirement for every app, but it is a meaningful hardening step when you handle sensitive data, want stronger opener isolation, or need features that browsers gate behind crossOriginIsolated. The key is to deploy it intentionally, because one incompatible third-party resource can break the page.

Code Example

Cross-Origin-Opener-Policy: same-origin
Cross-Origin-Embedder-Policy: require-corp
Cross-Origin-Resource-Policy: same-origin
if (!self.crossOriginIsolated) {
  console.warn('This page is not cross-origin isolated yet.')
}

Why It Matters

COOP and COEP change how the browser groups documents and what cross-origin resources may be embedded. Combined with compatible subresource responses, they reduce classes of opener-based and cross-origin leak risks and unlock isolated-only APIs.

  • better protection against opener-based cross-origin attacks and XS-Leaks
  • required for certain high-capability features such as SharedArrayBuffer
  • clearer trust boundaries around what third-party resources can join the page
  • higher deployment risk if assets, popups, or embeds are not audited first

Best Practices

Roll out COOP and COEP together when the document truly needs isolation

For full cross-origin isolation, the common pattern is:

Cross-Origin-Opener-Policy: same-origin
Cross-Origin-Embedder-Policy: require-corp

Then verify in the browser:

console.log(self.crossOriginIsolated)

Audit every cross-origin dependency first

COEP changes what your page is allowed to embed. Review:

  • scripts
  • fonts
  • images
  • iframes
  • workers
  • analytics and tag-manager integrations

Any cross-origin resource loaded under COEP must opt in through CORS or CORP.

Be deliberate about popup flows

OAuth, payment, and support popup flows often rely on opener relationships. If your app depends on those behaviors, test them explicitly before enforcing COOP and choose the narrowest compatible setting.

Thresholds

  • Pass if intended routes return compatible COOP and COEP headers and self.crossOriginIsolated === true where isolation is required.
  • Fail if the app depends on isolated-only APIs but the runtime is not actually cross-origin isolated.
  • Fail if critical popup or embed flows break under the enforced header set.

Exceptions

  • Most sites do not need full cross-origin isolation. Add it when you need the security boundary or the gated browser capabilities, not as a fashionable default.
  • A route-specific rollout can be safer than enabling the headers globally if only a small subset of the app needs isolated-only features.
  • Some third-party content simply will not work under COEP. Replacing or isolating that dependency may be required before rollout.

Support Notes

  • Compatibility and third-party breakage matter more than the header syntax alone, so verify against the project's actual browser support policy and dependency set.
  • Isolation should be proven by runtime behavior such as self.crossOriginIsolated, not only by seeing headers in the response.

Verification

Automated Checks

  • Inspect representative document responses and confirm COOP and COEP are present where intended.
  • Inspect critical subresource responses and confirm they provide compatible CORS or CORP behavior.

Manual Checks

  • Open the page in a browser and check self.crossOriginIsolated.
  • Test popup, OAuth, payment, analytics, and embed flows in a staging environment.
  • Fail the rollout if the app depends on isolated-only APIs but self.crossOriginIsolated is still false, or if critical third-party integrations stop working.

Use with AI

Copy these prompts to use with your AI assistant, or install the MCP server to use directly from Claude, Cursor, or Windsurf.

Check

Verify implementation

Review security headers and embedded resources for cross-origin isolation. Check whether the app needs COOP/COEP, whether resources are compatible with COEP, and whether the runtime actually becomes crossOriginIsolated.

Fix

Auto-fix issues

Add COOP and COEP only after auditing dependencies, ensure subresources use CORP or CORS as required, and verify the final document becomes crossOriginIsolated in the browser.

Explain

Learn more

Explain how COOP, COEP, and CORP work together, what they protect against, and why third-party embeds often block a successful rollout.

Review

Code review

Review server headers, third-party integrations, popups, workers, and asset responses related to Use COOP, COEP, and CORP for cross-origin isolation when needed. Flag exact responses or integrations that would block isolation or break once isolation is enforced.

Sources

References used to support the guidance in this rule.

Further Reading

Tools and supplementary material for exploring the topic in more depth.

Mozilla Observatory
observatory.mozilla.orgTool

Rules that often go hand-in-hand with this one.

Implement a content security policy

A Content Security Policy is implemented to prevent XSS attacks and control resource loading.

Security
Set a Permissions-Policy header

The Permissions-Policy header lets servers restrict which browser features (camera, microphone, geolocation, etc.) can be used in a page or its embedded iframes.

Security
Handle cross-origin requests securely

Use CORS correctly, validate message origins with postMessage, and understand the Same-Origin Policy to prevent cross-origin attacks.

JavaScript
Set an X-Frame-Options header

The X-Frame-Options header controls whether your page can be embedded in an iframe, frame, or object — preventing clickjacking attacks.

Security

Was this rule helpful?

Your feedback helps improve rule quality. This stays internal for now.

Loading feedback...
0 / 385