-
Notifications
You must be signed in to change notification settings - Fork 31
Preload and SRI #127
Comments
As we discussed earlier in the week, I think it's reasonable to allow developers to specify an |
I think it's unfortunate to place extra complexity on users, but understand that codebase complexity may not be trivial as well. Would it be sufficient to include a preload signal that indicates that SRI would be needed, and what hash function would be used? That way the SRI verification can only be done when the e.g. would |
@yoavweiss Yes, that's enough. I will be happy with that option as well. |
(As we discussed internally) I'm very supportive of this idea, and the alternative suggested by @yoavweiss sounds good to me too, especially if it could make the developers' life easier. |
If we're going to specify an integrity attribute, it seems reasonable to use it (and to discard the preloaded resource if it doesn't match). I'm not sure there's much value in hinting at a hashing function alone. |
The hint will enable the engine to collect the right hash value of the resource without storing its bytes until it is matched with a script/style. |
+1 for supporting integrity enforcement on preload. Related discussion: w3c/webappsec-subresource-integrity#26 Re, function vs value: are there use cases where value would enable enforcement where it's not possible today? E.g. if I preload a response that's later consumed via fetch(), it would be nice to defer to preload to do the validation, albeit there is the wrinkle here that if validation fails than preload can't simply drop the bytes but would instead need to return a failed response to fetch()? @yoavweiss I understand your motivation, but I'm also a little hesitant of overloading and special casing "integrity" value here with hashes. If we go down this route, perhaps we should consider a different attribute name? |
Per discussion at TPAC 2018 on 10/25/2018:
@yoavweiss , can you please edit the spec or find an editor to make this update? |
Correct. Chrome's motivation is originally to just be able to obtain the hash digest of the preload resource before throwing the bytes away, but having developers specify the integrity also allows us to perform SRI validation on the preload itself. Fetch specifies that a preload that fails, the response becomes a network error. It's important that this network error is stored in the preload cache and can be "matched" with, or else the developer can write:
..and expect the preload to do the SRI gatekeeping. If the preload failed SRI verification and we discard the response, an insecure script will fetched, likely against developer expectation. I'll start preparing some spec changes. |
Another concern that I think seems un-addressed is: How should preload + SRI work for resources that the SRI spec currently doesn't support? E.g., SRI spec only supports links + scripts, but
The spec can't really effected quite yet (until preload cache is ~finished I'd say), but knowing people's opinions on this would help with the Chrome implementation in the mean time :) |
Saying something like "UA must check the validity of the response if its integrity metadata is specified and UA supports the integrity check for the destination" and leaving other cases as optional (e.g. MAY check) sounds fine with me, while open to other options. |
@yoavweiss @igrigorik @domfarolino are we going to follow up with allowing |
Wondering if this was ever enabled in Chrome browsers? If anyone has a link to the Chrome developer thread discussing this I'd be interested in reading more. |
We, Chrome, have some difficulty to support script preload with SRI. Here is the story:
We spent months to solve the issue in our codebase, but we've given it up due to complexity the solution would bring.
I think, instead, we could ask web developers to specify the integrity value at the link element. For example,
doesn't match
while
does.
What do you think about this idea?
The text was updated successfully, but these errors were encountered: