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

Use "navigation request's policy container's CSP list" instead of "navigation request's client's global object's CSP list" #692

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mbrodesser-Igalia
Copy link

@mbrodesser-Igalia mbrodesser-Igalia commented Nov 25, 2024

Complements #494 in order to make the spec consistent.

Preparation for fixing whatwg/html#4651.


Preview | Diff

…vigation request's client's global object's CSP list"

Complements #494 in order make
the spec consistent.

Preparation to fix whatwg/html#4651.
@antosart
Copy link
Member

I think the problem with this is that navigation request's policy container is initially "client" and is only updated to the source document's policy container thing during fetch (https://fetch.spec.whatwg.org/#concept-request-policy-container), while javascript: url navigations do not go through fetch. I think if you want this to work you need to set navigation request's policy container before this check is called from html.

Or am I missing anything?

@mbrodesser-Igalia
Copy link
Author

I think the problem with this is that navigation request's policy container is initially "client" and is only updated to the source document's policy container thing during fetch (https://fetch.spec.whatwg.org/#concept-request-policy-container), while javascript: url navigations do not go through fetch.

Correct.

There seems to be another issue, which should be addressed outside of this PR:

The request's policy container is set only in 1, step 12. "should navigation request of type be blocked by Content Security Policy?" is called from 2, step 19.3. 1 is called from step 19.5 of 2. So during the first iteration of the while-loop at step 19 of 2, the request's policy container will be its default value, "client". 3 doesn't handle "client", though.

I think if you want this to work you need to set navigation request's policy container before this check is called from html.

Yes.

The call from html, 4, step 5 is already broken since the request's client isn't set.

A corrective way forward here would be to merge this PR only together with setting the navigation request's policy container in the HTML spec. WDYT?

Or am I missing anything?

Footnotes

  1. https://fetch.spec.whatwg.org/#concept-fetch 2

  2. https://html.spec.whatwg.org/multipage/browsing-the-web.html#create-navigation-params-by-fetching 2 3

  3. https://www.w3.org/TR/CSP3/#should-block-navigation-request

  4. https://html.spec.whatwg.org/multipage/browsing-the-web.html#the-javascript:-url-special-case

@antosart
Copy link
Member

Right! Thanks for the deep investigation, this makes sense to me.

I agree the best thing is to set navigation request's policy container in html before calling the CSP check.

@ciaramcmullin ciaramcmullin added agenda+ To be discussed at a triage meeting blocked Unable to proceed due to pending work or discussion. and removed agenda+ To be discussed at a triage meeting labels Dec 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocked Unable to proceed due to pending work or discussion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants