Repository navigation
Conversation
This upstreams the monkeypatches from https://wicg.github.io/nav-speculation/speculation-rules.html#content-security-policy. At a high level, the additions are: - A new directive, `inline-speculation-rules`, which can be used if developers want to block inline JavaScript `<script>`s but allow inline `<script type=speculationrules>`s. This is done by introducing a new script type, `script speculationrules`, to sit alongside the existing `script` and `script attribute` types; HTML passes this new value in. - Handling of the new `"speculationrules"` request destination, which is used by the `Speculation-Rules` HTTP header. It cannot be blocked by CSP.
22806ee to
4e8aad7
Compare
|
We don't need the keyword |
|
IIUC (please correct me if wrong) this PR contains a major behavior changes that would break existing websites without updates to pages' CSP : To avoid breakage, pages should e.g. add cc/ @tunetheweb @nhiroki WDYT? FYI Also see whatwg/html#11697 (comment) whatwg/html#11697 (comment) and around for previous context for direction/planning around external speculation rules. |
|
Also this PR applies |
|
Yes I thought we’d previously agreed that the HTTP Header version was out of scope? Because if you’ve the ability to set HTTP Headers then you’ve no guarantees on CSP anyway (since that is also usually set via HTTP Headers). Also can I understand what this does for |
|
CSP should apply to links in HTTP headers as well to remain consistent. |
|
Hi all, based on the latest discussion here, particularly the concern about breaking existing pages (#808 (comment)), I propose this revised plan to avoid breakage until Stage 1 - external
Stage 2 -
Note on What do you all think? If this sounds right, I can proceed with updating the specs and CL for Stage 1. |
|
The incremental approach looks good to me (it's more like whatwg/html#11697 (comment) ), but I defer to @tunetheweb (speculation rules ecosystem) and @antosart (CSP) for details -- WDYT? |
|
Wrt your proposed plan, I believe it mostly applies to your implementation:
If that's correct, the spec change looks fine to me modulo the comment above. |
7112c2f to
65da675
Compare
@antosart I believe we are on the same page, we won't define |
|
From my perspective this is a step backwards rather than forwards, for a number of reasons:
I agree As to the whether HTTP Header Speculation Rules should be subject to CSP at all, that seems a separate conversation to what @vickiez seems interested in solving here ( |
|
I see what you mean, I have no objection to adding Thanks for providing the customer context for exempting the header, I’ll revive the conversation on the Fetch spec. For now, can we proceed with the |
|
So some further comments/questions, since we didn't get to close this out at TPAC this week. On-page It seems, from reading the PR, that I still think there is a migration strategy necessary from Questions on I'm not 100% clear on how all this works with The The The first a) (no For the second b) issue ( @annevk /@arturjanc / @mikewest what are your thoughts on whether If that exemption was still a concern, then Cloudflare would need to again inject a Alternatively, CDNs could just move away from the HTTP header completely given the CSP complications, and the rules could be injected with an on-page script instead. That could be easier with the new |
|
Thanks for the summary @tunetheweb. I briefly discussed this with @vickiez on a separate email thread, but wanted to bring that discussion here, primarily on CDN side concerns that we should keep in mind for a possible solution:
I believe it is important to separate the transport mechanism from the payload. If the HTTP header itself can remain a CSP-exempt delivery mechanism (requiring no nonces), the new However, when |
|
To address @annevk's consistency concern: header-initiated speculation rules fetches should be under CSP, but not through
Precedent: CSP already picks the directive by how a resource is loaded, not by its type. Scripts loaded via Why:
what do you think @annevk? |
|
I don't really understand why this would be different from style sheets which have exactly the same considerations? In particular they don't have a distinct directive for But bypassing CSP (or any security policy) is much worse for consistency so I guess it seems acceptable, though not ideal. |
10/22 update: We propose adding
speculation-rules-srcfor inline and external script-element rules while preserving the current CSP exemption forSpeculation-Rulesheader fetches, to avoid disrupting automatic deployments. Header coverage remains an open question for the TPAC WebAppSec discussion, where we hope to agree on a direction informed by affected providers’ deployment constraints and potential compatibility impact.The current PR diff still applies CSP to header fetches; the proposal above revises that scope and is not yet reflected in the diff. The original summary below describes the existing diff, not an agreed final plan.
Adds the following:
From #776:
New additions:
speculation-rules-srcfetch directive that restricts the sources from which speculation rules may be loaded, whether via <script> elements or the Speculation-Rules HTTP response headerspeculation-rules-src→script-src-elem→script-src→default-src, applied uniformly to both inline and external speculation rulesspeculation-rules-src(removing the previous header exemption that returned null).This reflects the agreed plan from whatwg/html#11697
Preview | Diff