A developer named Tute Costa revealed that an update issued for the ‘strong_password’ Ruby gem contained malicious code that enabled an attacker to remotely perform random code.
The developer was updating gems used by a Rails application when he observed that version 0.0.7 of strong_password was pushed out on RubyGems.org, the Ruby community’s gem hosting service, but not on GitHub.
Strong_password is a Ruby gem that can be integrated into their applications to guarantee that the passwords being set are strong. The gem has been downloaded nearly 250,000 times, including over 38,000 times in the case of version 0.0.6.
Released on June 25, an examination of strong_password 0.0.7, discovered that a few lines of code had been added to the end of a file. The code was intended to wait for an arbitrary number of seconds, check if the application using the gem was running in production and, if so, draw and run code from a Pastebin post.
Since the Pastebin post was editable, the attacker could have changed the payload at any time.
After revealing the malicious code, Costa reached out to the developer of strong_password, Brian McManus, who said someone had hijacked the gem and he had lost ownership. After being alerted by Costa, RubyGems representatives pulled the malicious version, locked the account used by the attacker, and assigned McManus as the owner of the gem.
Regrettably, data from rubygems.com displays that the malicious version was downloaded 537 times before it was drawn.
Many people have discussed the incident on Hacker News, with some expressing concern that the attack may have been the outcome of a susceptibility hitting the entire Ruby ecosystem. Others believe the attacker almost certainly compromised the gem developer’s account. Some believe a powerful susceptibility would have possibly been exploited against a much more popular gem, while others believe this may have been part of a beleaguered attack.
This is not the first time a malicious Ruby gem has been exposed this year. In late March, someone pushed out a malicious version of bootstrap-sass, which has approximately 29 million downloads. The spiteful version comprised a furtive backdoor that enabled attackers to perform random commands on server-side Rails applications.