Skip to content
This repository was archived by the owner on Jun 30, 2023. It is now read-only.

Why are prefetch links optionally blockable instead of blockable? #70

Closed
bzbarsky opened this issue Jan 24, 2017 · 15 comments
Closed

Why are prefetch links optionally blockable instead of blockable? #70

bzbarsky opened this issue Jan 24, 2017 · 15 comments

Comments

@bzbarsky
Copy link

And specifically, why are UAs prevented from treating them as blockable? What is the benefit of making them optionally blockable that outweighs the problems with it?

@dveditz
Copy link
Member

dveditz commented Jan 24, 2017

I assume they are optionally blockable like images because the risk is info leaking over an insecure channel (cookies, urls, etc) and not compromising the integrity of the context like scripts. Unless we don't get a second chance at upgrading a prefetched script to block it later?

@bzbarsky
Copy link
Author

I suppose, but at least Gecko treats lots of stuff as "blockable" that is a smaller attack vector than scripts (e.g. <a ping>). The comment above the list of "blockable" things there says:

// Active content (or content with a low value/risk-of-blocking ratio)

so it's not just the severity of not blocking that's relevant but also the risk/benefit ratio of not blocking in general...

@igrigorik
Copy link
Member

igrigorik commented Jan 24, 2017 via email

@bzbarsky
Copy link
Author

Hmm. Which browsers? Certainly Gecko treats prefetch as non-optionally blockable....

@bzbarsky
Copy link
Author

As for language, you could just say that the loads should be considered either blockable or optionally blockable. That seems pretty straightforward.

I guess one can even write tests for that by including the <meta> tag that opts into blocking for optionally blockable things.

@yoavweiss
Copy link
Contributor

@bzbarsky: Do you see security issues with allowing prefetch requests to be optionally blockable?

@bzbarsky
Copy link
Author

I'm not the right person to ask. You should probably talk to the Gecko security folks, who currently have them blockable.

But really, it's a question of what your threat model is.

@mikewest
Copy link
Member

It seems like the behavior should fall out of the way y'all call into Fetch (see step 4ish of https://w3c.github.io/webappsec-mixed-content/#should-block-fetch). https://w3c.github.io/resource-hints/#fetching-the-resource-hint-link doesn't really make that relationship clear, however. Do you set the initiator/type/destination in some other document?

Regardless, I'm happy to change Blink's behavior to match Firefox's. If it's getting away with tighter restrictions than Blink is, then Blink should match.

@bzbarsky
Copy link
Author

https://w3c.github.io/webappsec-mixed-content/#should-block-fetch

Pretty sure this text far postdates anything Gecko has implemented in this area, so it's not really relevant to what we do in practice.

But even if we follow this algorithm... requests "destination" is not "document" for prefetches, right? So we go on past step 1. Step 2 is not relevant in the no-CSP case. Step 3, let's say none of the conditions match. Step 4 it looks to me like none of the conditions would match, at first glance.... So step 5 would return blocked.

@mikewest
Copy link
Member

https://w3c.github.io/webappsec-mixed-content/#should-block-fetch

Pretty sure this text far postdates anything Gecko has implemented in this area, so it's not really relevant to what we do in practice.

It's relevant insofar as I hope it ends up describing what we'd like to be doing in practice.

But even if we follow this algorithm... requests "destination" is not "document" for prefetches, right?

It's pretty unclear to me how prefetches are fetched. I agree that they're unlikely to be fetched as "document", though. :)

So we go on past step 1. Step 2 is not relevant in the no-CSP case. Step 3, let's say none of the conditions match. Step 4 it looks to me like none of the conditions would match, at first glance.... So step 5 would return blocked.

Step 4 is the question, I think. Are prefetched resources using as, etc to fetch the resource? If so, I could imagine prefetch-as-image being allowed but prefetch-as-script being blocked.

In general, though, I'm perfectly happy just blocking all non-secure prefetch requests. If y'all can explain to me how they're represented to Fetch, I'm happy to rewrite that section of MIX accordingly.

@bzbarsky
Copy link
Author

Are prefetched resources using as, etc to fetch the resource?

We're talking about the non-"as" case here (not least because this is the first I've heard of "as"!). I agree that for the "as" case applying the policy we'd normally use for the type it's being prefetched "as" makes sense.

I have at this point more or less lost track of the rats' nest of information Fetch takes as input, so I'm afraid I can't tell you anything useful about how prefetches should be represented there... :(

@bzbarsky
Copy link
Author

Oh, and the one thing that I would like to see here is some clarification around what "optionally-blockable" means. Because it does NOT mean "not blocked by default", really. And the fact that its definition doesn't match the conditions in https://w3c.github.io/webappsec-mixed-content/#should-block-fetch step 4 just confuses everything....

It would probably be better in terms of spec clarity to drop the concept of "optionally-blockable" altogether, replace step 3 substep 1 with "The user agent is configured to block all mixed content" or something (and similar for https://w3c.github.io/webappsec-mixed-content/#should-block-response step 2 substep 1), and have things that want to not be blocked by default be explicitly added to step 4 of https://w3c.github.io/webappsec-mixed-content/#should-block-fetch and step 3 of https://w3c.github.io/webappsec-mixed-content/#should-block-response (or better yet some algorithm both of those call into, if their behavior is meant to be identical).

@toddreifsteck toddreifsteck added this to the Level 1 milestone Nov 7, 2017
@mikewest
Copy link
Member

We discussed this in the WebAppSec group at TPAC, and agreed there that we'd prefer to align on Firefox's behavior with regard to prefetch. (The minutes aren't great, but they capture the conclusion, at least!)

I believe that falls out of the mixed content spec's current language in https://w3c.github.io/webappsec-mixed-content/#should-block-fetch (though I'll reiterate that it would be helpful if the resource hints spec actually described the fetching in terms of Fetch so that the integration was clearer). :)

Thanks!

@yoavweiss
Copy link
Contributor

Should be specified when tackling #86

/cc @noamr

@noamr
Copy link
Contributor

noamr commented Mar 27, 2023

This is in the HTML spec now and fully specified.

@noamr noamr closed this as completed Mar 27, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

7 participants