News for hackers. Stuff that matters.
Re:jQuery.com Malware Attack Puts Privileged Enterprise IT A... by jimrandomh on Tuesday September 23, 2014 @01:12PM (#8356482)
As others have observed, if the attackers had wanted, they could have modified the hosted jQuery scripts and used them to attack other web sites. They don't seem to have done so, but this highlights how the practice of including scripts hosted by other parties is a security problem for the Internet as a whole.

But there's an easy way to fix it. Browsers should support a hash attribute for <script> tags, so instead of

    <script src="https://code.jquery.com/jquery-2.1.1.min.js">
sites could instead say

    <script src="https://code.jquery.com/jquery-2.1.1.min.js" hash="sha256:874706b2b1311a0719b5267f7d1cf803057e367e94ae1ff7bf78c5450d30f5d4">
This would also significantly reduce the risks from use of http instead of https, and from weaknesses in https itself.
Re:jQuery.com Malware Attack Puts Privileged Enterprise IT A... by Igglyboo on Tuesday September 23, 2014 @01:25PM (#8356570)
The other benefit to this is that the browser can be confident that it's cached copy matches the requested file and we can now cache files that come from different hosts.

Example: User has jquery cached from googles CDN, jquery will not be loaded from microsofts cdn because it has the same hash.

Re:jQuery.com Malware Attack Puts Privileged Enterprise IT A... by robertduncan on Tuesday September 23, 2014 @02:40PM (#8357248)
Re:jQuery.com Malware Attack Puts Privileged Enterprise IT A... by Someone1234 on Tuesday September 23, 2014 @03:33PM (#8357635)
I have a few issues with this proposal e.g.

> 3.2.1 Agility: the user agent will choose the strongest hash function in the list

Aside from the fact this contradicts the next section (Priority), it also would discourage browser vendors from adding better (slower) hashing functions as then they would be "forced" to utilise them.

Instead the standard should be: The "the fastest hash function which the browser finds secure." So if SHA-256 and SHA-512 were available, it would use SHA-256 until it was found insecure, then the browser would use SHA-512.

> Validation using unsupported hash functions always fails (see the “Does resource match metadataList” algorithm below). Authors are therefore encouraged to use strong hash functions, and to begin migrating to stronger hash functions as they become available.

No. Just no. If Chrome was the first to market with e.g. SHA-9999, I'd be unable to utilise that until literally every single browser on the market supported it (as it was fail by default).

Imagine if this standard existed in the IE6 days, today if you tried to use SHA-512 (which, let's assume, IE6 didn't support) the resources would fail to load every time (and you'd wind up having half a dozen different hashes just to hit something that was supported).

It should just ignore unknown hash functions, not fail. If the integrity attribute only had one hash function and it was unsupported then the entire attribute should be discarded.

Fail by default isn't even the HTML way. Ignore by default is.

Re:jQuery.com Malware Attack Puts Privileged Enterprise IT A... by jrochkind1 on Tuesday September 23, 2014 @09:19PM (#8359417)
> It should just ignore unknown hash functions, not fail. If the integrity attribute only had one hash function and it was unsupported then the entire attribute should be discarded.

Your proposal would make the hash attribute advisory. If I put a hash attribute on there, should I be able to count on it, and know that browsers won't load unless they can verify it? Or is it just advisory, and browsers may choose to ignore it, and I can't actually count on browsers only loading if hash matches?

Of course, I guess the fact that older browsers will always exist that ignore it (and that all browsers are essentially untrusted software, as far as the developer is concerned) may point to "you'd best consider it advisory only" anyway, I suppose.

Re:jQuery.com Malware Attack Puts Privileged Enterprise IT A... by wtallis on Tuesday September 23, 2014 @09:40PM (#8359482)
Even without considering older browsers, the hash will be deliberately ignored by some clients for things like NoScript surrogates. Every tag and attribute is just advisory to the client; the client can always do what the user wants instead of what the server wants.
Re:jQuery.com Malware Attack Puts Privileged Enterprise IT A... by acdha on Tuesday September 23, 2014 @08:51PM (#8359308)
… and the Blink team landed it today shortly after your comment:

https://codereview.chromium.org/566083003/

The tests show how simple the code is:

https://codereview.chromium.org/566083003/patch/120001/13000...

Re:jQuery.com Malware Attack Puts Privileged Enterprise IT A... by thirsteh on Tuesday September 23, 2014 @01:27PM (#8356601)
And what happens when it's patched to fix a real issue? Your site will just break.

Just don't trust so many third parties with your site's security: Host jQuery (and other things) yourself.

Re:jQuery.com Malware Attack Puts Privileged Enterprise IT A... by Drakim on Tuesday September 23, 2014 @01:37PM (#8356699)
Nah, the new version is hosted at a new url.

Even if we ignore the hash suggestion, you don't want to have some dev on the other side of the planet suddenly update one of your libraries on your live website.

That should never be a thing in the first place, so it won't be a problem.

Re:jQuery.com Malware Attack Puts Privileged Enterprise IT A... by johnduhart on Tuesday September 23, 2014 @01:31PM (#8356635)
>And what happens when it's patched to fix a real issue? Your site will just break.

No, they will release a new version with a new URL.

Re:jQuery.com Malware Attack Puts Privileged Enterprise IT A... by 0x0 on Tuesday September 23, 2014 @01:31PM (#8356636)
Then you update the version number and the hash, just like you have to update the version number today already :)
Re:jQuery.com Malware Attack Puts Privileged Enterprise IT A... by Igglyboo on Tuesday September 23, 2014 @02:45PM (#8357283)
The URL will change along with the version and hash number, unless you're using jquery-latest.min.js which is a bad idea in general and wouldn't make sense to use with the hash attribute anyways.
Re:jQuery.com Malware Attack Puts Privileged Enterprise IT A... by teraflop on Tuesday September 23, 2014 @01:18PM (#8356521)
This was suggested on the WHATWG mailing list last December, but AFAIK no action has been taken yet: http://lists.whatwg.org/pipermail/whatwg-whatwg.org/2013-Dec...
Re:jQuery.com Malware Attack Puts Privileged Enterprise IT A... by maw on Tuesday September 23, 2014 @02:43PM (#8357268)
Yep, a lot of people have come up with this idea independently (I'm one of them). It's pretty obvious, after all.

But I don't think it will ever get much traction. Believe it or not, it's too far beyond the organizational and technical capacities of the people behind too many sites. The benefit, aside from slightly improved caching, will be minimal.

And if you're careful and meticulous you aren't doing braindead things like hotlinking javascript in the first place.

Re:jQuery.com Malware Attack Puts Privileged Enterprise IT A... by thomasfromcdnjs on Tuesday September 23, 2014 @03:18PM (#8357535)
Thomas chiming in from cdnjs.com here.

We are responsible for quite a lot of copy and paste script includes these days and could potentially push people in this direction.

If anyone is serious about investigating hash'ed includes shoot me an email with your thoughts, my email can be found on my HN profile.

Re:jQuery.com Malware Attack Puts Privileged Enterprise IT A... by acdha on Tuesday September 23, 2014 @02:53PM (#8357350)
The thing which will give it traction[1] is performance: if a browser starts letting you host locally but say “Yes, this is the same jQuery you have in your cache” that'll be a big win for a number of sites, particularly on mobile where it could reduce expensive network traffic and reduce cache duplication.

http://www.w3.org/TR/SRI/

Re:jQuery.com Malware Attack Puts Privileged Enterprise IT A... by Someone1234 on Tuesday September 23, 2014 @03:09PM (#8357476)
You assume that such people wouldn't just copy/paste a code fragment. If that code fragment happened to already come with a hash/CRC, they likely won't remove it.
Re:jQuery.com Malware Attack Puts Privileged Enterprise IT A... by krapp on Tuesday September 23, 2014 @01:21PM (#8356538)
I really like this idea. Is this something browser plugins would be able to do?
Re:jQuery.com Malware Attack Puts Privileged Enterprise IT A... by aikah on Tuesday September 23, 2014 @02:31PM (#8357170)
I guess, but it would have to download the script before hand,check the hash,then append the script somewhere. I dont see any other technique."document.write" is only efficient while the page itself is loading.

It's an interesting problem nevertheless, and could be extended to any link or src attributes in tags.

In case the hash and the file dont match,the browser wouldnt load that file.

Re:jQuery.com Malware Attack Puts Privileged Enterprise IT A... by jimrandomh on Tuesday September 23, 2014 @02:07PM (#8356979)
I don't think a plugin could do it, but it's back- and forward-compatible enough that it makes sense to just go ahead and add it to a browser without waiting for standardization.
Re:jQuery.com Malware Attack Puts Privileged Enterprise IT A... by alexjeffrey on Tuesday September 23, 2014 @02:55PM (#8357369)
realistically you would want to use a merkle tree to hash the source, to make it more secure against a chosen plaintext collision, but aside from that this'd be a great addition.
Re:jQuery.com Malware Attack Puts Privileged Enterprise IT A... by nightcracker on Tuesday September 23, 2014 @09:25PM (#8359433)
No secure hash function has collisions, so it's not necessary.
Re:jQuery.com Malware Attack Puts Privileged Enterprise IT A... by TheCoelacanth on Wednesday September 24, 2014 @01:27PM (#8362781)
Every hash function has collisions. It's just nearly impossible to find them if the hash function is secure.
Re:jQuery.com Malware Attack Puts Privileged Enterprise IT A... by alexjeffrey on Wednesday September 24, 2014 @02:20PM (#8363144)
... and it's impossible to know for sure that a hash is secure against collisions. For example, MD5 was the standard for hashing for quite some time but is considered broken today due to attacks that have since been discovered. By implementing the hashing using merkle trees, you increase the avalanche effect relative to the data, making it much harder to force a collision.
Re:jQuery.com Malware Attack Puts Privileged Enterprise IT A... by nightcracker on Wednesday September 24, 2014 @08:30PM (#8364919)
Obviously any compression function has collisions - this is a mathematical fact. What I mean with "no secure hash function has collisions" is that if you are using a secure hash function you shouldn't need extra defenses against collisions attacks as the "secure" in "secure hash function" implies those attacks are infeasible.
Re:jQuery.com Malware Attack Puts Privileged Enterprise IT A... by kpatrick on Tuesday September 23, 2014 @04:38PM (#8358048)
IBM also has a patent pending on this.