Cross-Origin-Opener-Policy (COOP)
The Cross-Origin-Opener-Policy (COOP) HTTP response header allows you to ensure a top-level document does not share a browsing context group with cross-origin documents.
Why COOP is Important
When a website opens another website (for example, via window.open() or a link with target="_blank"), both documents traditionally share the same browsing context group. This allows a malicious cross-origin site to retain a direct JavaScript reference to your window (window.opener), enabling attacks such as:
- Tabnabbing: Silently redirecting your open tab to a fake phishing login page while you browse other tabs.
- Cross-Site Leaks (XS-Leaks): Probing window properties, history length, or frame counts to deduce private user information.
- Spectre Side-Channel Attacks: Sharing an OS process with an untrusted site, allowing malicious code to read memory addresses across origins.
Supported Directives
Cross-Origin-Opener-Policy: same-origin
COOP supports three directives:
same-origin(Recommended for Maximum Security): Isolates your document in its own browsing context group. Cross-origin documents opening your site (or opened by your site) will NOT have a reference to your window.same-origin-allow-popups: Retains references to popups that either don't set COOP or opt out by settingunsafe-none. Ideal if your site uses third-party OAuth popup login flows.unsafe-none: The default browser behavior. The document can share a browsing context group with its opener.
Recommended Configuration
Apache (.htaccess)
Header always set Cross-Origin-Opener-Policy "same-origin"
Nginx
add_header Cross-Origin-Opener-Policy 'same-origin' always;
Cross-Origin Isolation for A++
When combined with Cross-Origin-Embedder-Policy: credentialless, COOP completes the requirements for full Cross-Origin Isolation. This awards significant bonus points on SecurityHeaders.nl and is required for the coveted A++ grade.