-
Notifications
You must be signed in to change notification settings - Fork 83
Consider relaxing prefetch-src
and preload as
#542
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 seems reasonable. |
This is not 100% true for |
It's included as long as it doesn't have |
When prefetching a resource (or preconnecting to an origin), the destination of the request is unknown and also not important. e.g. if this resource is a script and would be disallowed by `script-src`, the directive would be invoked again when the response is about to be consumed and would be rejected then. The only security measure valid for prefetch/preconnect is to avoid exfiltration - i.e. block the request when the default directive blocks this URL and no other directive allows it. Closes w3c#542
Should Fetch be updated to reflect the removal of this? It still refers to |
Yes! Good catch, thanks |
+1 |
Reading through past decision like introducing
prefetch-src
and yet-to-be-decided issues like CSP forpreconnect
anddns-prefetch
, I believe we can improve the way these resource hints integrate with CSP. I would like to propose an alternate viewpoint.The goals of CSP are to prevent:
A
preload
and aprefetch
(and to a greater degree,preconnect
anddns-prefetch
) are not in themselves able to "inject content" - their content is not used by the document until discovered by a subsequent fetch that would have to pass CSP checks again. IIUC, the only risk with those hints is exfiltration. Unless there are things CSP comes to prevent that I'm anaware of.With content injection, the type of resource matters. e.g. you want to allow embedding an image from some particular CDN, but not execute scripts.
But with exfiltration, the type of resource does not make any difference. If cross-origin images are allowed but not scripts, you can still send out requests by piggy-backing them on images.
So, the only way to really prevent exfiltration, is by having something like
default-src: none
ordefault-src: self
- thus preventing all types of resources from making requests.So my suggestion is:
prefetch
,preconnect
,dns-prefetch
(and optionallypreload
withoutas
) would default to the most lenient directive in the current policy regarding the URL in questionprefetch-src
would still be valid, as a way to relax restictions only for resource hintsThe text was updated successfully, but these errors were encountered: