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

guidance on inheritance between contexts #111

Open
wanderview opened this issue Oct 30, 2018 · 12 comments
Open

guidance on inheritance between contexts #111

wanderview opened this issue Oct 30, 2018 · 12 comments
Assignees

Comments

@wanderview
Copy link

wanderview commented Oct 30, 2018

There are a number of places in the web platform where some policy or state is inherited from one context to another. Its up to each feature in the platform to define how it gets inherited or not. The result is that there are a number of inconsistent inheritance behaviors.

Some downsides of this inconsistent behavior are:

  1. Confusing API surface for developers.
  2. Special case logic is required in implementations resulting in brittleness and increased security risk. (Many of the policies have security implications.)
  3. Increased cost to specifying a new feature because inheritance must be figured out again for each feature individually.

It might be nice to have some guidance on how inheritance should work on the web platform to produce a more consistent system.

Off the top of my head I can think of the following types of inheritance:

There are probably more cases to consider.

My personal preference would be to make all inheritable attributes align to the same source. So if a local URL inherits an origin from a context, then all other attributes are inherited from that same source context. If a context has its own URL that defines its own origin, then nothing is inherited from other contexts.

Thanks for your help sorting this out!

@annevk
Copy link
Member

annevk commented Oct 30, 2018

(Note that I've found at least one case where we have to inherit into dedicated workers (though alternatively we could treat this header as setting a policy for the agent cluster, which seems somewhat attractive in a way and would sidestep this inheritance question): Upgrade-No-CORS.)

@nhiroki
Copy link

nhiroki commented Sep 18, 2019

  • referrer policy: I believe referrer policy is inherited from documents to a dedicated worker, but I'm less sure about this one.

In the current HTML spec, a dedicated worker doesn't inherit its parent's referrer policy (whatwg/html#3270)

@nhiroki
Copy link

nhiroki commented Sep 18, 2019

  1. Special case logic is required in implementations resulting in brittleness and increased security risk. (Many of the policies have security implications.)

+1. This inconsistency makes the Blink implementation and WPT complicated. cc: @hiroshige-g

@annevk
Copy link
Member

annevk commented Sep 19, 2019

@nhiroki did you see whatwg/html#4916?

@nhiroki
Copy link

nhiroki commented Sep 25, 2019

@annevk Sorry for the late reply. Yes, I read the issue.

I heard there was a discussion about the policy inheritance at TPAC from @hiroshige-g. I'll update/close whatwg/html#3270 based on the final decision.

@hiroshige-g
Copy link

We (mainly @mikewest @annevk @wanderview @hiroshige-g) had a discussion around TPAC 2019, and reached a consensus:
NOT to inherit parent context's policy, except for <iframe srcdoc>,
<iframe src="about:blank">, data: dedicated workers etc., and use the same inheritance rule across policies (CSP, referrer policy, etc).
@annevk's whatwg/html#4926 is based on the discussion.

More detailed summary is here:
https://docs.google.com/document/d/1CAegq63QY0HMW-66zG4wgawIaWGi33MHtmU3azQQNz8/edit?usp=sharing

@hiroshige-g
Copy link

@annevk please let me know if I'm missing something or not summarizing correctly.

@annevk
Copy link
Member

annevk commented Sep 26, 2019

Thanks for writing that up @hiroshige-g, looks good to me!

@hober
Copy link
Contributor

hober commented May 28, 2020

@kenchris and I took a look at this during the TAG F2F this week. We're really happy that the TPAC discussion was so fruitful. We'll hold off on adding something to the Design Principles document until whatwg/html#4926 is resolved. Thanks!

@hiroshige-g
Copy link

FYI some updates:
I'm doing some investigation to see how policies etc. are set in different contexts and how (in)consistent they are.
I've found some issues (e.g. whatwg/html#5474 whatwg/html#421) but they look relatively minor.

I also investigated the of feasibility of changing CSP inheritance rule. Originally I was wondering comparing CSPs of parent Documents and worker script's response headers and seeing whether they are the same, but when I looked at some major websites, they set different policies (due to nonce, due to minor diffs, or just setting completely different CSPs).

@torgo torgo modified the milestones: 2020-08-10-week, 2020-09-07 Aug 10, 2020
@kenchris
Copy link
Contributor

kenchris commented Sep 7, 2020

@hiroshige-g Do you think some recommendations can be crafted from your investigation? In which case what would they be?

@kenchris
Copy link
Contributor

Friendly ping @hiroshige-g !

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

No branches or pull requests

8 participants