-
Notifications
You must be signed in to change notification settings - Fork 349
CSP Request Header and CORS preflight fetch. #52
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
Comments
That certainly seems terrible, and isn't what I intended with that addition. @annevk, wdyt? |
I see three problems. 1. It's not clear when this header is supposed to be set and therefore it's not clear whether e.g. service workers are supposed to be able to observe it. 2. This header can be set by |
Ping! |
The goal is to inform a page that any redirect they perform is potentially observable (in a binary "Happened" or "Didn't happen." sense). We plugged the whole which made the endpoint completely observable, so I've been less interested in figuring out this header, as it's less valuable than it used to be. That said:
|
If we don't think this is needed anymore, happy to not add it. Will leave it open so we can reconsider when CSP is rewritten. |
There's a similar known issue regarding the EventSource (https://html.spec.whatwg.org/multipage/comms.html#last-event-id). It sends out Last-Event-ID. It's currently treated as a non-simple header and Chromium's ServiceWorker would issue a preflight for it (cc/ @horo-t). In a different context, we're about to exempt the There could be more stuffs like this coming that are intended to be observable/alterable by a ServiceWorker. For the Last-Event-ID, I think we can just add it to the simple header list and leave it open to XHR/Fetch (i.e. leave it not forbidden). |
@tyoshino in part it really depends on when the header is set. Is it set at the "feature level", the "fetch level", the "service worker level", or the "just prior to network level". The theoretical security problem with adding headers to the simple header list is that they can then be set to any value, thereby potentially compromising the security of a server which would not be affected otherwise (since it assumes that for logged in users the value will always be correct). I would love to figure out what the best solution for that is. @igrigorik wants to know it too I think. And so does @jakearchibald. |
Yeah. Regarding My initial impression for |
Agreed about What does Chrome's network security team think about that? I'm also not sure what Mozilla thinks on this matter, FWIW. It's always a little muddy on the edges of the same-origin policy. |
Related Client-Hint threads:
FWIW, being able to observe CH headers within SW is an important use case. Similarly, requests initiated by fetch() and within SW should advertise appropriate UA-set CH headers. Does it make sense to allow UA-set headers to be treated as "simple headers", and trigger a preflight if set or modified by the developer? |
That would make headers more complex than they currently are, or require a side table I suppose. (Alternatively, you could go with validation and allow both developers and user agents the same kind of syntax.) None of these is very attractive, but perhaps that is the best option? |
Hmm, well.. The CH spec does specify the BNF for each header. It doesn't seem like a far stretch to make UA require a validation step for the provided values? |
We could I suppose, if user agents implement it... So it'd be something like: 'A simple header is ... or a header whose name is "CH header 1", "CH header 2", or ... and whose value, once parsed, is not failure.' |
- Last-Event-ID is defined in the HTML spec as a utf-8 string, hence we don't place any restrictions on its value - Each Client Hints header has a BNF grammar that should be validated by the user agent; the header is defined as simple if the name of the header matches one of CH header names, and its value conforms to the defined grammar Closes: - whatwg#52 - httpwg/http-extensions#141
- DPR, Save-Data, Viewport-Width are sent on navigation requests - Subresource requests are subject to the set client hints policy - Client Hints headers are treated as simple headers: each Client Hints heaer has a BNF grammar that should be validated bythe user agent. Closes: - whatwg#52 - httpwg/http-extensions#141
- DPR, Save-Data, Viewport-Width are sent on navigation requests - Subresource requests are subject to the set client hints policy - Client Hints headers are treated as simple headers: each Client Hints heaer has a BNF grammar that should be validated bythe user agent. Closes: - whatwg#52 - httpwg/http-extensions#141
- DPR, Save-Data, Viewport-Width are sent on navigation requests - Subresource requests are subject to the set client hints policy - Client Hints headers are treated as simple headers: each Client Hints heaer has a BNF grammar that should be validated bythe user agent. Closes: - whatwg#52 - httpwg/http-extensions#141
I'm not sure what plans we have, if any, for Client-Hints, but I filed this gecko bug: |
According to the CSP spec
https://w3c.github.io/webappsec/specs/content-security-policy/#csp-request-header
But "CSP" is not a simple header
https://fetch.spec.whatwg.org/#simple-header
So when the user agent requests a cross-origin resource which CSP is set, it must send a CORS preflight fetch.
This means when we use CSP, we can't use CDN which doesn't support CORS preflight.
Is this my understanding correct?
The text was updated successfully, but these errors were encountered: