3 ms·
One of these days, I'd like to have a scheme for referencing secure third-party content that includes hashes. I'm never going to link to a third-party server f
by JoshTriplett 12y ago
One of these days, I'd like to have a scheme for referencing secure third-party content that includes hashes. I'm never going to link to a third-party server for some JavaScript file that could be changed out from under me, but if I can link to it on a CDN along with a sha256 or similar, and have it grabbed from my own server instead if the hash doesn't match, great!
I've seen a few attempts at that, but nothing that has actually taken off. It needs an appropriate polyfill, so that in browsers that don't support it, either the content gets downloaded and hashed client-side, or the content just gets downloaded from the same origin.
> In the new secure-by-default world, what happens if a website has some large assets (e.g. video, game files) and would like to opt into caching by any transparent proxies that may be on the user's network?
The whole concept of a "transparent" proxy will hopefully die in a secure-only world. If you want some server on your network to MITM your traffic (for caching or any other reason), use a non-transparent proxy. (Or, install a CA certificate from your proxy, but hopefully widespread use of certificate pinning will kill that too.)
- bzbarsky 12y agoFor what it's worth, http://w3c.github.io/webappsec/specs/subresourceintegrity/ http://w3c.github.io/webappsec/specs/subresourceintegrity/ is actively being worked on, and implementations in Chrome and Firefox are on the way in the near future. The polyfill issue is handled in that proposal as described in <http://w3c.github.io/webappsec/specs/subresourceintegrity/#fallback-1> http://w3c.github.io/webappsec/specs/subresourceintegrity/#f...: Your "src" attribute points to a server you control, but your "noncanonical-src" points to the CDN, and a browser that knows about "noncanonical-src" is also supposed to know about the "integrity" attribute and ensure that the content it gets hashes to what you expect.
- hrjet 12y agoThis is very interesting; thanks! I am not very familiar with hashing algorithms, but why isn't the length of the content specified in the `integrity` attribute? Wouldn't it help avoid length extension attacks?
- JoshTriplett 12y agoA good digest alorithm should already handle length extension attacks with just the digest. HMAC algorithms handle that as far as I know, and I think modern hashes don't suffer from the length extension problem in the first place.
- comex 12y agoIn any case, length extension attacks apply to (hashes misused as) keyed message authentication codes - a scenario where you give a message and its authenticator to a server knowing the key, and it checks whether someone knowing the key generated them. The attacks let you, given a message and its authenticator, calculate the authenticator for a different message. However, in this case, the hash cannot be tampered with; breaking integrity would require finding a different message with the same hash, which is a straight-up collision, considered to totally break a hash algorithm. At the moment, the only commonly used hash algorithm with known collisions is MD5; SHA-1 will probably follow in the next several years.
- hrjet 12y agoI perhaps used the wrong term. I meant straight-up collision with a modified length. The known MD5 collision attack needs to modify the length of the message; finding a collision with the same length is extremely difficult. It would be reasonable to assume that attacks on other hashing algorithms would suffer the same constraint. Wouldn't having the length specified in the integrity attribute help reduce chances of a future attack? The cost of specifying the length is negligible; about 12 bytes for a base-64 encoded 64-bit unsigned int.
- sjy 12y agoYou're essentially using the length as a(n extremely weak) secondary hash in that case. That might be sufficient to disable one known MD5 exploit, but if you're worried about vulnerabilities in your primary hash algorithm it would make more sense to use another real hash algorithm for your backup.
- metromoxie 12y agoJust as a further set of links regarding subresource integrity in Chromium, you can try it today on Canary Chrome behind the "Enable experimental Web Platform features" flag. You can follow the feature's development here: https://code.google.com/p/chromium/issues/detail?id=355467 https://code.google.com/p/chromium/issues/detail?id=355467 In fact, we're having a rather heated discussion on the security-dev@chromium.org mailing list right now, if anyone wants to follow along: https://groups.google.com/a/chromium.org/forum/#!topic/security-dev/hJwYZOOPaH4 https://groups.google.com/a/chromium.org/forum/#!topic/secur...
- Animats 12y agoI'd like to have a scheme for referencing secure third-party content that includes hashes. All that's really needed is a convention that a URL parameter of the form "example.com/.../sha3hash-nnnnnnnnn" indicates the secure hash of the page to be served. Cache systems can cache such pages, but if they change them in any way, the change can be detected. This removes the need to encrypt publicly available static information. It doesn't require a secure certificate. Most importantly, it means you can use a content-delivery network without letting it have MITM privileges on secure content. HTTPS Everywhere means Cloudflare gets to see all your users's passwords. That's not a good thing.
- JoshTriplett 12y agoEncryption makes sense even for publically available static information. You're not just protecting the contents of the information; you're protecting the knowledge that that specific user accessed it. And I certainly wouldn't advocate giving a CDN permission to MITM your own domain. Give it its own dedicated domain, serve content from that domain via HTTPS, and don't let that domain have any user-specific information.
- Animats 12y agoAnd I certainly wouldn't advocate giving a CDN permission to MITM your own domain. That's how Cloudflare works. At least 36,000 domains let Cloudflare act as a MITM for them. Including "news.ycombinator.com". This is the price of "HTTPS Everywhere" security theater. Also, if you know the IP address and the length, you can often figure out what static content was accessed.
- comex 12y agoIt's not like CloudFlare can't see passwords if you don't use HTTPS. I don't think it's security theater, because CloudFlare being compromised is only one out of a large class of potential attacks. That said, I fully agree that it would be nice to not have to trust CloudFlare.
- nitrogen 12y ago
- xorcist 12y agoWhy would you link to some third party javascript if you could tag it with an sha256 hash? The idea of third party javascript hosting is to make caching across sites possible. But the hash is a better way to do that. And unless your visitors are all international, they're going to have a better cache miss experience.