News for hackers. Stuff that matters.
Re:Strong_password Rubygem hijacked by nneonneo on Sunday July 07, 2019 @05:01PM (#20377827)
This is a gem that checks the strength of a user-submitted password. It has a large number of downloads (37,000 on the legitimate 0.0.6 version). It looks like it's made to be integrated on webservers.

The modified gem downloaded and executed code stored in a editable Pastebin, meaning that the code could have changed at any time. Presumably, the malicious code would activate just by browsing any page on the affected site. One version of the Pastebin code would execute any code embedded in a magic cookie sent by a client. Plus, it would ping the attacker's server to let them know your webserver was infected.

Nasty, nasty stuff.

Re:Strong_password Rubygem hijacked by djur on Sunday July 07, 2019 @06:19PM (#20378343)
Good analysis, but I'm not sure about "a large number of downloads". Download counts can be pretty inflated due to CI/deployment processes that reinstall gems from scratch repeatedly. I've seen open-sourced gems that never got any real usage outside their original company get that number of downloads.

To add a bit of a sense of scale here, the popular Devise gem that's used for authentication in many Rails apps has 52.7 million total downloads and almost 20k stars on GitHub. strong_password has 247k total downloads and 191 stars. It has three reverse dependencies, none of which I've ever heard of and none of which have any of their own reverse dependencies.

This suggests to me that this gem is used by less than 1% of Ruby web apps (probably substantially less) and, more importantly, if you have a dependency on this gem you probably know (because it'd be a direct dependency in your Gemfile, not a dependency of a dependency).

Re:Strong_password Rubygem hijacked by marcus_holmes on Monday July 08, 2019 @11:00AM (#20383291)
So...we can all ignore how a popular ruby gem was hijacked and used to infect production webservers with malware because (to paraphrase) "it wasn't that popular"?

This was caught because the author diligently checked their dependencies line by line. How many ruby devs do that?

How many other gems are already hijacked but haven't been discovered because no-one has audited them? That number is almost certainly non-zero.

This is on Rubygems.org. They have enough information to warn devs that the gem might be infected (months since the maintainer logged in, gem version release without github repo changes, maintainer email on haveIbeenpwned and no password change since that date, etc).

Re:Strong_password Rubygem hijacked by djur on Monday July 08, 2019 @04:51PM (#20386630)
No, I didn't say that, and I would prefer that you not put words in my mouth. I was responding to a single statement in the parent comment that I thought was inaccurate.

> a [...] ruby gem was hijacked and used to infect production webservers with malware

I wasn't aware of any reports of this being exploited in production. Do you have an example?

I agree with the rest of your comment about the need for more active measures on the part of Rubygems.org and the likelihood that other gems -- especially infrequently used, semi-abandoned ones like this -- have been hijacked without anyone detecting.

Re:Strong_password Rubygem hijacked by marcus_holmes on Monday July 08, 2019 @06:48PM (#20387466)
fair point, sorry for the implied impugn.

no, I don't have any examples, but then, it's not likely we're going to hear of any - anyone affected is probably unaware (until now, maybe). I guess some might come out of the woodwork now.

But again, Rubygems should have data on who downloaded this version of this gem, and so should be able to warn them, and even publish that data so we know not to visit their sites until they acknowledge and fix.

Re:Strong_password Rubygem hijacked by pharrington on Sunday July 07, 2019 @06:20PM (#20378346)
> This is a gem that checks the strength of a user-submitted password

Does it, though?

https://github.com/bdmac/strong_password/blob/master/lib/str...

Re:Strong_password Rubygem hijacked by fasterdom on Sunday July 07, 2019 @06:25PM (#20378374)
Indeed, replacing this with the list of top 100 passwords would be much more effective.
Re:Strong_password Rubygem hijacked by cyphar on Sunday July 07, 2019 @07:08PM (#20378599)
Or, alternatively, switching to the haveibeenpwned API[1] or zxcvbn[2].

[1]: https://haveibeenpwned.com/API/v2 [2]: https://github.com/dropbox/zxcvbn

Re:Strong_password Rubygem hijacked by alister on Sunday July 07, 2019 @06:43PM (#20378473)
It seems to do that too (comparing against a list of the top 500 passwords):

https://github.com/bdmac/strong_password/blob/master/lib/str...

Re:Strong_password Rubygem hijacked by senorprogrammer on Sunday July 07, 2019 @10:11PM (#20379407)
A long time ago I made a gem that does pretty much this: https://github.com/senorprogrammer/pil

If you want this functionality, I recommend not using it as-is, given the security vuln GitHub is currently reporting. Rather, anyone has my permission to copy the code verbatim into your project. It's a pretty simple gem.

Re:Strong_password Rubygem hijacked by audience_mem on Monday July 08, 2019 @05:10PM (#20386794)
Could you clarify?

Is the algorithm deficient?

To me that looks like code that indeed checks the strength, so I must be missing something.

Re:Strong_password Rubygem hijacked by pharrington on Tuesday July 09, 2019 @02:36PM (#20395163)
It checks the length of a password, along with an arbitrary scalar for repeated characters. It does not do any entropy calculations.

The writer of that code at least needs to read https://nvlpubs.nist.gov/nistpubs/legacy/sp/nistspecialpubli... one more time.

Re:Strong_password Rubygem hijacked by michaelcampbell on Sunday July 07, 2019 @08:15PM (#20378914)
And, only in "production" mode. >:-\