DEV Community

StarkMan
StarkMan

Posted on

Cross-Origin-Opener-Policy separates browsing contexts, not user accounts

Cross-Origin-Opener-Policy separates browsing contexts, not user accounts

A page can open a cross-origin window and retain an opener relationship. That relationship allows limited access to the new browsing context and can expose navigation behavior that a security team did not intend. The Cross-Origin-Opener-Policy response header lets a document request a different opener policy. It is useful isolation, but it does not authenticate users or protect data after an attacker reaches the same origin.

The HTML Standard defines three main values. unsafe-none is the current default and keeps the new document in the same top-level browsing context as its predecessor unless another policy applies. same-origin-allow-popups creates a new context unless the predecessor has the same policy and is same origin. same-origin also requires auxiliary browsing contexts to contain same-origin documents with the same policy, or they appear closed to the opener.

What changes in the browser

A switch to a separate browsing context group can sever direct references such as window.opener. That reduces cross-window scripting and some navigation attacks. It can also break legitimate popup flows, including consent screens, payment windows, and legacy single sign-on journeys. The policy should be applied through the application's response layer and tested across each popup use case.

COOP does not prevent a script on the same origin from reading the page, exfiltrating cookies, or changing the DOM. It also does not make a response private in the HTTP cache or authorize an API. Cross-origin isolation is a related browser feature that also depends on Cross-Origin-Embedder-Policy; setting COOP alone is not a general isolation switch.

A policy migration should inventory top-level documents, popup producers, popup consumers, and authentication redirects. Add Cross-Origin-Opener-Policy: same-origin or same-origin-allow-popups where the application can tolerate the behavior, verify the header on error pages as well as successful HTML responses, and collect browser violation reports where supported.

Browsers may enforce the policy differently across redirects and opener chains. Test a popup that remains same origin, a popup that crosses origins, a popup that redirects back, and a page that tries to call window.opener after the policy applies. Record the expected result for each flow instead of assuming the browser will preserve the old object graph.

COOP is a boundary around a browsing context. It can remove an unnecessary opener capability, but it cannot make an insecure application safe. Authentication, authorization, and origin isolation still require separate controls.

References

Top comments (0)