Consider moving away from document.domain to adhere to better security practices #29590
Labels
browser: chrome
browser: edge
browser: electron
browser: firefox
Cypress 14
Issues scoped for Cypress 14
topic: cookies 🍪
type: breaking change
Requires a new major release version
What would you like?
I would like to consider removing document.domain injection and making
cy.visit()
require a full navigation when a subdomain navigation occurs, changing the cookie APIs to set the cookie on the current domain (not super domain), and to better adhere to full origin specifications without strange exceptions when it comes to origin and domain nomenclature.document.domain modification deprecation
The origin specification
Why is this needed?
With the introduction of Chrome 119, Chrome and other browsers now bucket all requests to an origin server with a given Origin-Agent-Cluster key:
Cypress ran into this in it's own system tests in #29391 and we patched a work around internally (see thread on PR).
This means the
Agent-Origin-Cluster
header needs to be set on the first page request. However, this is difficult for Cypress for a few reasons:Cypress only injects into
cy.origin()
or the Application Under Test (AUT). It is sometimes impossible to know when injection is going to be required in the future for a request that has already been sent to an origin server, which gives us two options:Agent-Origin-Cluster: ?0
on every origin server page request, which is not only a bad security practice, but almost guarantees we will be continuing an uphill battle fighting browser security, which we don't want.document.domain
injection, which would likely fix a slew of problems:window.top
domain is set first, which contrasts our best practices on test determinism. Adhereing closer to the browser specification and doing a document reload makes sure cookies are sent in the correct context.cy.origin()
now becomes more clear, which needs to be used on any origin navigation and not odd exceptions like sub domain navigation.Other
No response
The text was updated successfully, but these errors were encountered: