Malicious Code Planted in ‘strong_password’ Ruby Gem

A developer discovered that an update released for the ‘strong_password’ Ruby gem contained malicious code that allowed an attacker to remotely execute arbitrary code.

Developer Tute Costa was updating gems used by a Rails application when he noticed that version 0.0.7 of strong_password was pushed out on, the Ruby community’s gem hosting service, but not on GitHub.

Strong_password is a Ruby gem that developers can integrate into their applications to ensure 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.

An analysis of strong_password 0.0.7, released on June 25, revealed that a few lines of code had been appended to the end of a file. The code was designed to wait for a random number of seconds (up to one hour), check if the application using the gem was running in production and, if so, fetch and run code from a Pastebin post.

The Pastebin post was editable so the payload could have been changed by the attacker at any time.

After discovering 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.

The issue has been assigned the CVE identifier CVE-2019-13354. Rubysec, which provides security resources for the Ruby community, has advised users who installed version 0.0.7 to immediately downgrade to version 0.0.6.

Unfortunately, data from shows that the malicious version was downloaded 537 times before it was pulled.

The incident has been discussed by many on Hacker News. Some expressed concern that the attack may have been the result of a vulnerability affecting the entire Ruby ecosystem, while others believe the attacker most likely compromised the gem developer’s account. Some believe a powerful vulnerability would have likely been exploited against a much more popular gem — the most popular have tens and even hundreds of millions of downloads — while others think this may have been part of a targeted attack.

This is not the first time a malicious Ruby gem has been discovered this year. In late March, someone pushed out a malicious version of bootstrap-sass, which has roughly 29 million downloads. The malicious version included a stealthy backdoor that allowed attackers to execute arbitrary commands on server-side Rails applications.

Related: Cryptocurrency-Stealing Code Distributed via Popular Library

Related: Several Vulnerabilities Patched in RubyGems

Related: Researchers Uncover Critical RubyGems Vulnerabilities

Related: Critical Vulnerability Addressed in Popular Code Libraries

view counter

Eduard Kovacs (@EduardKovacs) is a contributing editor at SecurityWeek. He worked as a high school IT teacher for two years before starting a career in journalism as Softpedia’s security news reporter. Eduard holds a bachelor’s degree in industrial informatics and a master’s degree in computer techniques applied in electrical engineering.

Previous Columns by Eduard Kovacs:

Don't forget to share

You may also like...

Leave a Reply

Your email address will not be published.