[1] https://en.wikipedia.org/wiki/Web_Proxy_Auto-Discovery_Proto...
Of course, there are attacks that already work using cache timing, but that isn't a good thing.
There is Cache-Control: immutable
https://hacks.mozilla.org/2017/01/using-immutable-caching-to... https://bitsup.blogspot.de/2016/05/cache-control-immutable.h...
Not that many people use CSP, but that's the excuse I've heard for not allowing cross-origin caching.
The problem is that www.victim.example/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.
and from [2]:
0. evil.example hosts evil.js, <script src=evil.js integrity=foo>.
1. you visit evil.example and the browser stores evil.js with the cache key "foo".
2. you visit victim.example which has an XSS vulnerability, but victim.example thinks it is safe because it uses Content Security Policy and does not allow inline scripts or scripts form evil domains.
3. the XSS attack is loading <script src=www.victim.example/evil.js hash=foo>
4. the browser detects that "foo" is a known hash key and loads the evil.js from cache. Thinking that the file is hosted on victim.example - when the file is in fact not even present.
5. the evil.js script executes in the context of victim.example, even though they use a Content Security Policy to prevent XSS from being exploitable.
[1] https://news.ycombinator.com/item?id=10310594 [2] https://news.ycombinator.com/item?id=10311555 [3] https://news.ycombinator.com/item?id=10312333
(parts first posted here: https://news.ycombinator.com/item?id=13493407#13495482)
[5] https://news.ycombinator.com/item?id=13495482 [6] https://github.com/w3c/webappsec-subresource-integrity/issue...
You create a salt, send it to server.
The server adds the salt to the file, hashes it, then sends the hash back. You check this against the cached data.
When the hash doesn't match, you know either the cached version, or the server version, is wrong.
https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/If...
This article sums it up really, really well: https://hillbrad.github.io/sri-addressable-caching/sri-addre...
We blogged about Adblock detectors over here[1] a couple of months ago for BugReplay[2]. A major Adblock detector FAdBlock was using subresource integrity to detect whether it's payload was being blocked, ie when adblocker was blocking it from being loaded.
[1]: https://blog.bugreplay.com/2016/11/fkadblock-how-publishers-... [2]: https://www.bugreplay.com
As a caveat, there's info leaking here depending on whether the cache hits/misses, so this would need to be opt-in from the cache source, e.g. You set up subresource integrity and also say "allow other domains to load this resource from the cache."
Call it subresource sharing?
Edit: opt-in would need to be on both "sides" (sharer and sharee).
If the site doesn't want to leak that information, it doesn't participate in cache sharing. Since sharing is opt-in, sites won't unknowingly leak this information.
Edit: whoops. I see what you mean. I missed an edit while modifying an earlier draft and left the opt-in only on one side, the sharer.
Say I have jQuery previously loaded a page that included jQuery from CDNJS and now I'm in China and another site tries to load jQuery from Google's CDN.
Currently that request would get blocked by the great firewall. But since the browser should know that this file matches one it has seen (and cached) before it should be able to just serve the cached file.
This could also save a network request even if I'm linking to a self-hosted file on my own servers if I include the hash.