Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

responsePolicyContainer in "determine navigation params policy container" should be cloned for consistency #11060

Open
Lubrsi opened this issue Feb 20, 2025 · 4 comments
Labels

Comments

@Lubrsi
Copy link

Lubrsi commented Feb 20, 2025

What is the issue with the HTML Standard?

In determine navigation params policy container, step 4 states:

If responsePolicyContainer is not null, then return responsePolicyContainer.

The other steps in this algorithm either return a clone of a policy container, or a brand new policy container. responsePolicyContainer should be cloned to be consistent with the other steps.

This was noticed when implementing this algorithm in Ladybird:
https://github.com/LadybirdBrowser/ladybird/blob/1843a54df77f1b118bed07d92cafad4fef616f09/Libraries/LibWeb/HTML/Navigable.cpp#L640-L643

@domenic
Copy link
Member

domenic commented Feb 21, 2025

This generally appears to be kind of a mess. E.g. https://html.spec.whatwg.org/#beginning-navigation:determining-navigation-params-policy-container passes in a clone for the initiatorPolicyContainer argument, which is unnecessary. Other call sites do not.

I can't remember why we would or would not clone the policy containers here, so it might be equally valid to remove all the cloning.

@domenic domenic added topic: navigation topic: policy container The policy container proposal labels Feb 21, 2025
@annevk
Copy link
Member

annevk commented Feb 21, 2025

We need to clone policies when observing them "live" could result in race conditions. Imagine the referrer policy changing half-way through a fetch. That's something we want to avoid. (And realistically they'll have to pass a process boundary so some kind of copy will be needed anyway. So best to enforce that at a clear point in time.)

@domenic
Copy link
Member

domenic commented Feb 25, 2025

Sure, it's just not clear that this particular algorithm represents the relevant process hop. It's called from three very different call sites, all of which appear to be way after the initial step that goes in parallel.

If we wanted to be more disciplined about snapshotting, I guess we would add initiatorPolicyContainer and parentPolicyContainer to the source and target snapshot params, respectively, before we go in parallel. responsePolicyContainer comes from the network so I don't think it can change; cloning it is probably not necessary. historyPolicyContainer is presumably stored in the browser process. Should it be cloned?

I guess this would all be a lot clearer if we knew which parts of the policy container were mutable, if any. I guess CSP, due to <meta>? Anything else?

@annevk
Copy link
Member

annevk commented Feb 25, 2025

CSP and referrer policy are mutable. Not sure about embedder policy. Other policies are currently not listed as covered, though that's prolly wrong?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

3 participants