w3c / webappsec-subresource-integrity

WebAppSec Subresource Integrity
https://w3c.github.io/webappsec-subresource-integrity/
Other
70 stars 35 forks source link

Consider integrity enforcement of iframe #21

Open shekyan opened 8 years ago

shekyan commented 8 years ago

I can see enforcing integrity of iframe source can be useful when dealing with non-trusted origins.

annevk commented 8 years ago

How would this work with navigation of the contents? Or even the initial creation of <iframe> which will always load about:blank.

shekyan commented 8 years ago

It shouldn't. The way I see it is that integrity is checked for primary resource loaded with response code 2xx. (browsers can be helpful there and show supported digests of the content in "view source" tab). Once navigated away - let it load whatever. Integrity can also be checked if initial load is from data:, file:, filesystem:.

adon-at-work commented 7 years ago

đź‘Ť for supporting iframe integrity enforcement

as long as multiple integrity values are supported as documented in the spec, hash values of empty page (be it about:blank) and any allowed page navigations can be put all there as a whitelist.

dlongley commented 7 years ago

This would be tremendously useful for "mediator" polyfills that need to run on third party websites. For example, for the Payment Request and Payment Handler APIs.

annevk commented 7 years ago

This also fails badly for cross-origin <iframe> as integrity requires CORS, whereas navigation (which is what <iframe> uses) never uses CORS. I don't think this feature is really doable.

mikewest commented 7 years ago

@annevk: Never uses CORS, you say? I actually do want to change that for unrelated reasons in https://wicg.github.io/cors-rfc1918/, at least for preflights. If it's something you have fundamental objections to, we should talk. :)

annevk commented 7 years ago

I think the main problem is that CORS is about sharing content, but that's not really applicable in the <iframe> scenario. We would never want to grant cross-origin access to node trees. Using just CORS preflights seems somewhat reasonable, but a bit hackish as well. A dedicated signal might be more appropriate (especially if such servers could expect actual CORS traffic as well).

annevk commented 7 years ago

On closer inspection it seems you're already using new headers so it's likely fine. So then it's not really CORS.

mikewest commented 7 years ago

I think the main problem is that CORS is about sharing content, but that's not really applicable in the