News for hackers. Stuff that matters.
Re:Using Immutable Caching to Speed Up the Web by rwmj on Thursday January 26, 2017 @03:52PM (#13495157)
Powered by a content-addressable cache, where each object is identified by the hash of its content only: https://rwmj.wordpress.com/2013/09/09/half-baked-idea-conten...
Re:Using Immutable Caching to Speed Up the Web by niftich on Thursday January 26, 2017 @04:39PM (#13495482)
In a browser's current usage model, this is vulnerable to a 'cache origin confusion attack'. See this thread [1]. It's a bit hard to follow, so perhaps see these posts [2][3], which state the problem succinctly. Let me adapt the text from [3]:

The problem is that www.victim.com/evil.js doesn't exist, and never did, but your browser won't know that if it's in the cache -- this gives you a way of faking files existing on other servers at the URL of your choice, and as long as they're in the cache you'll get away with it.

[1] https://news.ycombinator.com/item?id=10310594 [2] https://news.ycombinator.com/item?id=10311555 [3] https://news.ycombinator.com/item?id=10312333

Re:Using Immutable Caching to Speed Up the Web by btrask on Thursday January 26, 2017 @06:45PM (#13496488)
This issue is discussed here, with what I think is a workable solution: https://github.com/w3c/webappsec-subresource-integrity/issue...
Re:Using Immutable Caching to Speed Up the Web by wanderr on Friday January 27, 2017 @04:24AM (#13498683)
I think the best way to fully quell the objections involves subresource integrity but I think the ideal way to deal would be to add a new attribute, sameas="https://canonical jquery link" or something along those lines. Then if the browser already has canonical jquery link AND the subresource integrity checks out it'll use that one. Otherwise it will load from wherever the developer specified and not be stored in a shared cache associated with the canonical jquery url in any way. Browsers can track references to sameas URLs that they keep getting cache misses on and go fetch them in the background for future use, possibly even going back and deleting the duplicates it had from before. This would allow developers to have a much greater chance that their libraries load from cache without adding more dns lookups and dependencies on cdns or servers they can't control.
Re:Using Immutable Caching to Speed Up the Web by saurik on Thursday January 26, 2017 @06:35PM (#13496431)
From that thread, "CSP already has a mechanism for hash-based whitelisting - if this is the only limitation, it'd be just as easy to allow cache-sharing whenever CSP is absent and/or the specific hash is explicitly white-listed." <- I totally understand the attack, but fail to see why it would be a problem if CSP actually does, in fact, have the ability to whitelist hashes (and looking at the spec, it does seem to, though I have not paid attention to CSP before and admit I could be misinterpreting the spec based on this prompt).
Re:Using Immutable Caching to Speed Up the Web by tetrep on Thursday January 26, 2017 @06:10PM (#13496246)
This is fixed by relying on CORS and using a key of (domain, hash) rather than just the hash.
Re:Using Immutable Caching to Speed Up the Web by woogley on Thursday January 26, 2017 @06:12PM (#13496261)
But then you're still downloading jQuery (or whatever) again for every unique domain
Re:Using Immutable Caching to Speed Up the Web by d33 on Thursday January 26, 2017 @06:34PM (#13496423)
Not if it points to a CDN.
Re:Using Immutable Caching to Speed Up the Web by woogley on Thursday January 26, 2017 @07:25PM (#13496699)
This brings us back to current status, as it defeats the purpose of normalizing arbitrary CDNs with the hash
Re:Using Immutable Caching to Speed Up the Web by elviejo on Thursday January 26, 2017 @04:40PM (#13495484)
And then using bit torrent to do colaborative transfer. If we are in the same LAN and I have a part of the file you are requesting, I'll feed it to you... so decrease network traffic in 90%
Re:Using Immutable Caching to Speed Up the Web by david-given on Thursday January 26, 2017 @04:50PM (#13495558)
Putting my devil's-advocate hat on:

What sort of failure modes are there when something inevitably goes wrong, either through malice, incompetence or sheer plain accident, and you end up serving different content from the same hash?

Re:Using Immutable Caching to Speed Up the Web by hueving on Thursday January 26, 2017 @05:09PM (#13495712)
If you've discovered a way to generate hash collisions with a modern crypto hashing algorithm, there is more glory to be had than screwing with people's browser caches.
Re:Using Immutable Caching to Speed Up the Web by cortesoft on Thursday January 26, 2017 @05:15PM (#13495760)
So lets skip the malice condition and go to the plain accident one; there are more chunks of content in the world than there are bits in any of the hashes we could use. We are eventually going to run into collisions.
Re:Using Immutable Caching to Speed Up the Web by Derander on Thursday January 26, 2017 @06:07PM (#13496222)
Arbitrary example: If you're using SHA256 you're emitting 256bit hashes. Hopefully the distribution of SHA256 outputs is indistinguishable from random (or close enough) or else we've got big problems in other domains.

If you're drawing at random from a pool of size k you need approximately sqrt(k) draws until you reach a ~50% chance of a collision[0].

With 256 bits, there are 2^256 possibilities, so following the rule-of-thumb you'd need 2^128 draws until you had a 50% chance of a collision.

2^128 > # of atoms in the universe.

If you adjust your risk tolerance you'll have different numbers come out, but the chance of a collision in any realistic scenario is negligible.

[0]: https://en.wikipedia.org/wiki/Birthday_problem

Re:Using Immutable Caching to Speed Up the Web by ycmbntrthrwaway on Thursday January 26, 2017 @05:48PM (#13496071)
> there are more chunks of content in the world than there are bits in any of the hashes we could use

The probability of collision is still negligible.

Re:Using Immutable Caching to Speed Up the Web by thinkloop on Thursday January 26, 2017 @05:52PM (#13496104)
Come on, you must know that hashes are astronomical, unpredictable and collision-free for any earthly purpose. If not, just add a bit.