Ruby on Rails Security Flaw Severe, but Not Widespread: Researcher

The developers for Ruby on Rails fixed a subtle bug in the Web development framework that could allow an attacker to take control of an application's database by SQL injection.

While the impact of the bug could be severe, most applications are not vulnerable unless they use Authlogic, a third-party authentication framework, and have exposed their secret session key. Most applications developed in-house will not be vulnerable, as their developers have generated a secret hash-based message authentication code (HMAC) to act as the key or password for the application's security, Hongli Lai, chief technology officer for Ruby development firm Phusion, wrote in an analysis of the vulnerability.

Yet, publicly available applications deployed by administrators without changing the key could be exploitable, he said.

"Open-source Rails apps, however, can form a problem," Lai stated. "Many of them come with a default session secret, but the user never customizes them, so all those instances end up using the same HMAC key, making them very easily exploitable."

Ruby on Rails is a Web application development framework based on Ruby, a language designed to minimize programmer confusion and maximize code reuse. Ruby on Rails is known for its ability to help Web users quickly prototype new sites and applications and is best known as the framework used to build the Basecamp project management system and Twitter's online site.

The security of users logged in to applications made with Ruby on Rails relies on developers treating the secret key with security in mind. However, many developers leak the file containing the key to application repositories such as Github when they check in the code, "joernchen," a hacker with the Phenoelit group, said in his own analysis.

"The simple problem is, that most developers are simply not aware of the confidentiality of this file," he wrote. As a result "they'll happily check it into Github or other online repositories," he noted.

Generally, Ruby on Rails will sanitize—also known as "escape"—program calls to its database object, ActiveRecord, to prevent an attacker from issuing commands to the database using a user-controlled input, such as a search box or log-in field.

The attack, known as SQL injection, is a popular and effective way to compromise the backend databases of Web sites that have not been adequately secured. The attacks are thought to be responsible for the compromises of two Sony sites and Oracle's MySQL.com site last year, as well as for the breach of Expedia's TripAdvisor site that allowed hackers to gain access to its customer list.

The flaw could impact Ruby on Rails applications in various ways. It could merely allow an attacker to log in as any user, without causing other damage. But it could result in a more serious data breach as well or just prove ineffective as an attack avenue, wrote Phusion's Lai.

"It really depends on what your app is doing," he said. "Since it is impossible to prove that something isn't insecure, you should take the vulnerability seriously and upgrade anyway even if you think you aren't affected."