Live data from Hacker News

Subresource Integrity

githubengineering.com

31–40 of 78 posts

Re: Subresource Integrity

#31
post #23

Earlier quoted context omitted.

How is that dangerous?

It leaks private user info -- a malicious server could include a JS file confirmed to be highly sensitive/top secret, and measure whether the client already has that cached. If so then the user is confirmed a sensitive target.

you could just add a new public=true option to counter this. I think you can even already check that with an iframe (or js head inject & timing) anyway, no need for CSP for that.

Re: Subresource Integrity

#33
post #28

Earlier quoted context omitted.

Signatures are taken care of by connecting via TLS. If a hypothetical attack breaks TLS or you don't use it, you can just change the public key served.

This is to prevent files on a 3rd party CDN from being loaded if they've been replaced with malicious ones.

A content hash is good enough. The trusted hash is sent over an already trusted channel (TLS).

Thanks for the downmods.

Re: Subresource Integrity

#34
post #28

Earlier quoted context omitted.

This is to prevent files on a 3rd party CDN from being loaded if they've been replaced with malicious ones.

A content hash is good enough. The trusted hash is sent over an already trusted channel (TLS). Thanks for the downmods.

The point is that with a signature you wouldn't have to change all the pages including the resource, but just sign the updated resource with the same key.

Re: Subresource Integrity

#35

Couldn't the great chinese firewall just intercept Github.com's HTML page as well and change the subresource integrity hashes? I thought that the Great Chinese Firewall already has the ability to penetrate SSL connections via some means.

The "Great Cannon" attack that they talk about in the blog post wasn't caused by replacing JS in GitHub pages. It replaced a Baidu Analytics script, used across the Chinese internet on thousands of websites, with a malicious one intended to DDOS GitHub from people's home browsers when these websites were accessed outside of China.

The way that this fixes the issue is by ensuring that the file being loaded on those thousands of websites is the correct one, and not the malicious attack script that was injected by the Chinese government or other such actors, otherwise it's not run at all.

Could the Chinese government rewrite the HTML of all these thousands of websites to also change the hash? Theoretically yes, but practically it makes it much more difficult.

Re: Subresource Integrity

#36
post #30

Edit : post below is right, nonces are only for inline scripts https://bugs.webkit.org/show_bug.cgi?id=89577 original: IIRC CSP already has hashes for resources, which also would handle this purpose. As a side note, there's at least one CDN already hosting fake copy of bootstrap - I've seen a mlicious extension loading it in my report-uri.io logs.

afaik CSP hashes are only for inline resources, but I could be wrong on that.

Re: Subresource Integrity

#37
post #34

Earlier quoted context omitted.

A content hash is good enough. The trusted hash is sent over an already trusted channel (TLS). Thanks for the downmods.

The point is that with a signature you wouldn't have to change all the pages including the resource, but just sign the updated resource with the same key.

It's just a semantic question. Does a URL point to a specific version of a resource or does it point to whatever the server considers to be the resource at a given time.

It would seem more desirable to be able to point to a specific version, instead of allowing a third party to be able to insert implicitly trusted code without acknowledgement.

Re: Subresource Integrity

#38
post #28

Earlier quoted context omitted.

Signatures are taken care of by connecting via TLS. If a hypothetical attack breaks TLS or you don't use it, you can just change the public key served.

This is to prevent files on a 3rd party CDN from being loaded if they've been replaced with malicious ones.

Ah, I see. I misunderstood. Though signatures seem to be just adding another part in the deployment process where you update the files themselves as well as the pages they're loaded from.

Is there any security gain from doing that?

Re: Subresource Integrity

#39
post #7

What about caching? If the HTML and the JS are both updated, but the browser receives the new version of one and the old version of another, this will break your page. (Since you'd now have to update the integrity attribute for every JS change, it means you run this risk every time you update your JS.) To be fair, running a mismatched version of the JS could already break things if the changes are big enough, but for…

SRI allows one to specify multiple hashes. In other words, to prevent this particular mismatch, one could include the hash of the new resource as well as the previous valid hash.

Re: Subresource Integrity

#40
post #34

Earlier quoted context omitted.

The point is that with a signature you wouldn't have to change all the pages including the resource, but just sign the updated resource with the same key.

It's just a semantic question. Does a URL point to a specific version of a resource or does it point to whatever the server considers to be the resource at a given time. It would seem more desirable to be able to point to a specific version, instead of allowing a third party to be able to insert implicitly trusted code without acknowledgement.

But if you need to sign updates, a third party CAN'T insert new code without it going through the site owner or a trusted party (e.g. new jQuery versions signed by the jQuery project). And it would seem desirable to be able to roll out a security fix without having to touch every single page that includes it (and the potential cache issues discussed above)
Post reply on HN