12 ms·
This could also be used to remove the need for a CDN for common libraries like jquery and similar resources. If the browser knows it has a file in its cache wit
by dspillett 11y ago
This could also be used to remove the need for a CDN for common libraries like jquery and similar resources. If the browser knows it has a file in its cache with the same properties (has, size, name) even if it come from a different site it can be pretty sure that the content is the same so no new request is needed.
So your site could use the cached copy of jquery (for instance) that was originally brought down to serve my site, or vice versa.
- sidarape 11y ago> size, name I don't see why it would be necessary to provide a name and a size. If the hash is the same, we can be pretty sure that's the same file.
- deleted 11y ago[deleted]
- lcswi 11y agoAn additional layer of security does not hurt. Forging a hash.collision at the exact same filesize is harder than an arbitrary size.
- emn13 11y agoThat's not really true. In fact, practical collision attacks vs. MD5 preserved the size - which if you think about it, makes sense. Unless a has function is utterly terrible, it's not unreasonable to assume it's easier to find a few correlated bits than it is to append bits. After all, to append bits you're going to need to somehow ensure that the internal fixed-size state of the hash algorithm cascades into the same state or nevertheless gives the same output, and since it's trivial to have a very, very high period state machine, that may mean appending huge numbers of bits. If safety were an argument you'd add an extra, unrelated hash function. E.g. even md5 is likely much harder to break if you also have the CRC32, even though CRC is a thoroughly insecure hash (and of course, you wouldn't use an insecure hash, now would you?)
- lcswi 11y agoThank you!
- dspillett 11y agoIt would not be necessary at all technically, but some people might be more reassured by the extra check.
- dspillett 11y agoYou are right that it would not be necessary at all technically, but some people might be more reassured by the extra check.
- Someone1234 11y agoI'm indifferent about name, but size has been shown to provide additional security. Generating two files where their hashes collide is extremely difficult. Generating two files where their hashes collide at the same size is near impossible, even after you break the hash function itself (e.g. with MD5 it requires much more compute power to generate two files with matching hashes and sizes than just hashes alone, since you're effectively looking for a subset of all collisions).
- sbierwagen 11y agoI feel like you're just effectively adding more bits to the hash length by appending the resource size; bits that might be better used by just adding more length to the hash.
- AgentME 11y agoAll MD5 hash collisions I've seen have been the same length: http://stackoverflow.com/questions/1224113/examples-of-hash-collisions http://stackoverflow.com/questions/1224113/examples-of-hash-.... I assume the common algorithm for making MD5 collisions requires you to start with a single value and mutate it in specific ways, while keeping the same length.
- sarciszewski 11y ago> it can be pretty sure that the content is the same so no new request is needed I'm really glad that the SHA-2 family of hash functions has held up thus far.
- strommen 11y agoThis would be a security problem. By measuring resource timing of a script copied from another site, one could determine if the browser has visited that other site. (Resource timing is disallowed for cross-domain resources for exactly this reason).
- reaktivo 11y agoCan you further explain? I can't see how this would work.
- michaelmior 11y agoYou can request to load a particular script that you know comes from a given site. If it loads instantly (for some value of "instantly"), then the request was almost certainly served from cache.
- madeofpalk 11y agoYou can do that at the moment. I made a site where I 'guessed' if a user was an employee of a certain company by embedding an <img> from an employee portal (from the login screen) and timing how long it took for onLoad to trigger. Times under a certain threshold indicated that the image was probably cached and they work there. Of course, once you load it once it's cached, so you need to persist the first result... but you get the drift.
- ohitsdom 11y agoThe <img> was from a different domain?
- madeofpalk 11y agoYes. Images work cross domain and they still fire onLoad correctly.
- detaro 11y agoOne could have sites opt-in to it, e.g. by a HTTP header? CDNs and other common resources could allow it, but identifying files would still be protected.
- bugmen0t 11y agoWe've been toying with this idea in earlier revisions of the spec, basically using the hash as a cache key and not loading the same file from websiteB if it has already been loaded form websiteA. Unfortunately, this could be used as a cache poisoning attack to bypass Content Security Policy. See the section about "Content addressable storage" at <https://frederik-braun.com/subresource-integrity.html https://frederik-braun.com/subresource-integrity.html>. (If you can come up with a magical solution to this problem, join the W3C web application security group mailing list and send us an email.)
- deleted 11y ago[deleted]
- benten10 11y agoHow about this: There's a warehouse 'owner' internal to the browser (and not exposed to pages/extension), who 'remembers' the resources the browser has, and the times it took to access them (for commonly-accessed resources). When a page requests the cached resource, the owner 'returns' the resource with a delay of whatever the original access time was, fudged around by some noise. A weakness of this would be that websites would be able to 'communicate' with each other by engineering response times to your browser, and then checking how long it takes your browser to access that. But this is a different scenario than random websites trying to figure out where else you've been: here the pages need to be in collusion with each other. The servers might try to use fancy algorithms to try to figure out if you're using cached versions by hitting different distributed servers and figuring out if the resource load time is an outlier. But that's prone to a lot of noise and other issues, and lesser of an issue than the original concern. Right? This obviously won't help with page load speeds, but will help network load for bot users and servers. One possible issue might be: if you've been in a slow connection previously, all your connections will seem slow even after you are in a faster connection. For that, you can just purge the cache and force the browser to reload the resources. Edited for formatting.
- sbierwagen 11y agoThe danger is not that malicious websites figure out where you've been, the danger is that a malicious website could poison the cache for a critical piece of JS used in, for example, gmail. Visit a malicious site, boom, Russians can read your email.
- michaelmior 11y agoI don't imagine any browser vendor implementing this at all. A hash collision seems unlikely but if it can be constructed, the results are potentially disastrous. No one else should be able to decide where code from site is loaded except me. "pretty sure" isn't really good enough.
- sarciszewski 11y agoNot sure why this is being downvoted. It's a reasonable point.
- icebraining 11y agoIt's not. If browser vendors thought that the potential for breaking a decent hash function was a real threat, they would also not implement HTTPS, signed updates, etc, all of which depend on the trust in hash based signatures.
- sarciszewski 11y agoI, for one, welcome EdDSA signing of Javascript resources.
- icebraining 11y agoThen developers who feel the same can simply not add any hash to their <script> tags, no?
- michaelmior 11y agoYes. And then not the security benefits that subresource integrity is intended to provide.
- icebraining 11y agoHTTPS, code and binaries signing, etc all depend on the fact that getting a malicious message with a hash signature that collides with another arbitrary message is all but impossible. If you don't trust that, you're pretty much unable to trust anything that's transmitted over the 'net, and this potential hole is not significant in that context.
- codedokode 11y agoDifferent sites usually use different versions of libraries. Also nowadays sites use to put caching headers for all their resources so the cache quickly gets filled. I think there would be low cache hit ratio.