Firefox Total Cookie Protection: Storage Access API user-gesture requirement during third-party iframe redirect chains
0 reputation · 19 Dec 2022, 16:47 UTC
0 reputation · 19 Dec 2022, 16:47 UTC
Firefox's Total Cookie Protection (TCP) partitions cookies and site data per top-level site. The Storage Access API (document.requestStorageAccess()) allows embedded cross-origin iframes to request access to their unpartitioned storage, but the specification requires a user gesture (transient activation) for the promise to resolve.
When a third-party iframe initiates a server-side redirect chain (for example, an OAuth identity provider flow), it is unclear whether Firefox treats the redirect as preserving the original user gesture for the purpose of granting storage access. The current implementation appears to deny access if requestStorageAccess() is not directly triggered by a user input event, yet the specification permits user-agent discretion for transient activation via redirects. This creates a gap for identity providers that rely on redirect-based authentication inside third-party iframes.
network.cookie.cookieBehavior=5 or privacy.partition.network_state=true).Does Firefox consider a redirect chain initiated by a user gesture on the top-level page as sufficient transient activation for requestStorageAccess() in a third-party iframe? If not, what specific user interaction pattern satisfies the requirement without breaking legitimate federated login flows?
35775 reputation · 20 Dec 2022, 00:18 UTC
No. Firefox does not reliably treat a top-level page click as transient activation for a third-party iframe that calls document.requestStorageAccess() only after a server-side redirect chain. Expect the promise to reject or storage access to be denied when the call runs in the document loaded by the redirect rather than in the document that received the original input event.
Confirmed: Total Cookie Protection partitions cookies and site data by top-level site when partitioning is enabled. document.requestStorageAccess() lets an embedded cross-origin iframe request unpartitioned access, and document.hasStorageAccess() reports the current grant. The call requires a secure context and genuine user interaction.
Likely explanation, not a Firefox guarantee: transient activation is scoped to the browsing-context document that handles the input. A server-side redirect loads a new document, so Firefox is not expected to carry the original top-level gesture into the final iframe document. Specification language about user-agent discretion does not require Firefox to preserve activation across redirect chains, and behavior can differ between Release, Beta, and Nightly.
document.requestStorageAccess() synchronously in the same event handler.postMessage handler.Log document.hasStorageAccess() before and after user actions in the iframe context. In Firefox DevTools, compare a top-level click that redirects the iframe through a server-side OAuth URL against a direct click inside the iframe before redirecting. Repeat on Release, Beta, and Nightly, and use channel-specific results rather than assuming redirect-chain activation. After a grant, inspect Storage Inspector for the identity provider's cookie in the iframe context; absence confirms denial.
Can the identity-provider iframe display and receive a direct user click? If no, the redirect-chain approach will not satisfy Firefox's gesture requirement, and you should use top-level or popup navigation instead.
Assumptions: this answer treats Firefox channel behavior and Storage Access API heuristics as unverified until tested in your environment. Enterprise policies, container tabs, private browsing, and enhanced tracking protection settings can override partitioning and grant behavior independently of gestures.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.