News for hackers. Stuff that matters.
Re:Do not let your CDN betray you: use subresource integrity... by yeldarb on Wednesday April 05, 2017 @11:18AM (#14042711)
It'd be cool if the browser used this to allow cross-origin caching as well.

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.

Re:Do not let your CDN betray you: use subresource integrity... by problems on Wednesday April 05, 2017 @11:33AM (#14042843)
The potential problem I see with this is that it could be abused for a "have you loaded this resource" privacy leak. Simply pick a unique script on a website, if my server doesn't get a hit then I know you went there before.
Re:Do not let your CDN betray you: use subresource integrity... by zrm on Wednesday April 05, 2017 @01:35PM (#14043884)
Possible solution is to have a content hash proxy trusted by the user but shared between multiple users. Then the site can only get the data at the proxy-level rather than the user-level, and not even that if the proxy is large enough to justify crawling the web to pre-cache everything, or is behind a larger cache that does.
Re:Do not let your CDN betray you: use subresource integrity... by nothrabannosir on Wednesday April 05, 2017 @02:07PM (#14044190)
That's not a solution but a work-around. The original privacy issue stands. browsers can't cache hashed content by default. :/
Re:Do not let your CDN betray you: use subresource integrity... by zrm on Wednesday April 05, 2017 @02:45PM (#14044493)
The browser would know if it had a content hash proxy configured and then could use it for all content hashed data. The issue becomes getting people to use one, but partial uptake is better than nothing. You could at least get most corporate and education environments with some equivalent to WPAD[1], and maybe even some consumer-level ISPs the same way if they want to reduce the traffic over their network.

[1] https://en.wikipedia.org/wiki/Web_Proxy_Auto-Discovery_Proto...

Re:Do not let your CDN betray you: use subresource integrity... by 3pt14159 on Wednesday April 05, 2017 @02:30PM (#14044388)
We already have that though. Images and HSTS headers.
Re:Do not let your CDN betray you: use subresource integrity... by problems on Wednesday April 05, 2017 @04:40PM (#14045420)
Those are abusable by first party only though aren't they? This abuse isn't just limited to fingerprinting from 1st party sources, but to 3rd party history detection essentially.
Re:Do not let your CDN betray you: use subresource integrity... by 3pt14159 on Thursday April 06, 2017 @08:11AM (#14049822)
Ah, thanks for clarifying. You are 100% right, I misunderstood the use case.
Re:Do not let your CDN betray you: use subresource integrity... by cryptarch on Wednesday April 05, 2017 @12:34PM (#14043342)
Save the load time and simulate it?
Re:Do not let your CDN betray you: use subresource integrity... by cryptarch on Thursday April 06, 2017 @04:44AM (#14048918)
Why do you think this would be a bad idea?
Re:Do not let your CDN betray you: use subresource integrity... by homakov on Wednesday April 05, 2017 @05:38PM (#14045875)
Who cares someone went to X website? Even https is not protecting from that.
Re:Do not let your CDN betray you: use subresource integrity... by staticassertion on Wednesday April 05, 2017 @05:54PM (#14045996)
If I visit website A it should not know that I also visited website B. HTTP or HTTPS is irrelevant - they are totally separate connections and this does not assume anyone is in the middle.

Of course, there are attacks that already work using cache timing, but that isn't a good thing.

Re:Do not let your CDN betray you: use subresource integrity... by homakov on Wednesday April 05, 2017 @06:49PM (#14046396)
I know a handful of attack that work, and a few more vectors that won't be fixed as well. So why bother, exactly? It's neither a big concern nor fixable in current web design.
Re:Do not let your CDN betray you: use subresource integrity... by renesd on Wednesday April 05, 2017 @11:23AM (#14042752)
Yeah, that would be cool. They could also even potentially save JIT typing, specialization, and even parsing. This is a big deal on mobile.

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...

Re:Do not let your CDN betray you: use subresource integrity... by throwaway2048 on Wednesday April 05, 2017 @11:52AM (#14042991)
Like every cross site cacheing scheme this could be abused for tracking purposes.
Re:Do not let your CDN betray you: use subresource integrity... by michaelt on Wednesday April 05, 2017 @11:46AM (#14042950)
Unfortunately this would break Content Security Policy.

Not that many people use CSP, but that's the excuse I've heard for not allowing cross-origin caching.

Re:Do not let your CDN betray you: use subresource integrity... by niftich on Wednesday April 05, 2017 @12:41PM (#14043397)
More detail on this: 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.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)

Re:Do not let your CDN betray you: use subresource integrity... by zrm on Wednesday April 05, 2017 @01:50PM (#14044020)
It seems like the problem is that you need to verify that the file actually exists there with the specified hash, but that isn't the same as having to download it. Is there a way to ask the server for just the hash of a file? You would still have the round trip to the server, but it would be a request for a 32 byte content hash rather than several orders of magnitude more data than that.
Re:Do not let your CDN betray you: use subresource integrity... by niftich on Wednesday April 05, 2017 @01:58PM (#14044095)
One of the replies to my similar post in the earlier thread [5] was from btrask who proposes a similar scheme, using a manifest placed in .well-known/, on the issue tracker for the W3C SRI spec [6]. The conversation is still ongoing, but see that for advantages and drawbacks, as well as other proposed solutions (and/or join the conversation!)

[5] https://news.ycombinator.com/item?id=13495482 [6] https://github.com/w3c/webappsec-subresource-integrity/issue...

Re:Do not let your CDN betray you: use subresource integrity... by Chris2048 on Friday April 07, 2017 @10:26AM (#14059875)
You mean a proof-of-existence challenge?

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.

Re:Do not let your CDN betray you: use subresource integrity... by emj on Thursday April 06, 2017 @04:44AM (#14048917)
The HTTP header If-None-Match is mentioned in your links, I don't see the problem with that, except ETags has their problems.

https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/If...

Re:Do not let your CDN betray you: use subresource integrity... by AgentME on Wednesday April 05, 2017 @01:37PM (#14043899)
More people should use CSP. It doesn't mean you have to stop worrying about XSS entirely, but it means that when it happens CSP can change it from being "a potentially wormable exploit that could be used to leak many users' data and kill your company" to "slightly annoying way the page formatting can be broken".
Re:Do not let your CDN betray you: use subresource integrity... by bugmen0t on Thursday April 06, 2017 @03:23AM (#14048611)
Yeah, it was discussed in the W3C WebAppSec group, but there are many unsolved challenges.

This article sums it up really, really well: https://hillbrad.github.io/sri-addressable-caching/sri-addre...

Re:Do not let your CDN betray you: use subresource integrity... by edibleEnergy on Thursday April 06, 2017 @12:11PM (#14051869)
Like any feature, there's a lot of weird edge casey parts of SRI that can be abused.

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

Re:Do not let your CDN betray you: use subresource integrity... by tetrep on Wednesday April 05, 2017 @11:32AM (#14042832)
> It'd be cool if the browser used this to allow cross-origin caching as well.

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).

Re:Do not let your CDN betray you: use subresource integrity... by throwaway2048 on Wednesday April 05, 2017 @12:14PM (#14043165)
This still wouldnt be enough, because you could still target the unique mix of script/script versions some specific site has, and have a high chance of being accurate, or at least high enough for statistical purposes.
Re:Do not let your CDN betray you: use subresource integrity... by tetrep on Wednesday April 05, 2017 @12:54PM (#14043502)
Why is it insufficient?

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.

Re:Do not let your CDN betray you: use subresource integrity... by problems on Wednesday April 05, 2017 @12:25PM (#14043265)
Given the accumulation of scripts from many sites it might work out alright, those specific versions could come from anywhere - not like only 1 site around uses a specific version of jquery or something. It might be enough, but would need testing to prove it out either way.
Re:Do not let your CDN betray you: use subresource integrity... by paulirish on Wednesday April 05, 2017 @04:19PM (#14045258)
https://hillbrad.github.io/sri-addressable-caching/sri-addre... captures that general idea; but I don't know if it has been pursued farther.
Re:Do not let your CDN betray you: use subresource integrity... by groby_b on Wednesday April 05, 2017 @04:52PM (#14045517)
It's being discussed, idly. No serious work AFAIK. There's a twitter thread or two...

https://twitter.com/cramforce/status/849621456111624192

https://twitter.com/hillbrad/status/848627295208300544