Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 418481 (CVE-2012-2660) - <dev-ruby/rails-{3.0.15,3.1.6,3.2.5}: SQL injection vulnerability (CVE-2012-{2660,2661})
Summary: <dev-ruby/rails-{3.0.15,3.1.6,3.2.5}: SQL injection vulnerability (CVE-2012-{...
Status: RESOLVED FIXED
Alias: CVE-2012-2660
Product: Gentoo Security
Classification: Unclassified
Component: Vulnerabilities (show other bugs)
Hardware: All Linux
: Normal trivial (vote)
Assignee: Gentoo Security
URL: http://weblog.rubyonrails.org/2012/5/...
Whiteboard: ~3 [noglsa]
Keywords:
Depends on: CVE-2012-2694
Blocks:
  Show dependency tree
 
Reported: 2012-06-01 06:49 UTC by Hans de Graaff
Modified: 2012-07-12 01:10 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Hans de Graaff gentoo-dev Security 2012-06-01 06:49:50 UTC
CVE-2012-2660 Ruby on Rails Active Record Unsafe Query Generation Risk

Impact
------
Due to the way Active Record interprets parameters in combination with the way that Rack parses query parameters, it is possible for an attacker to issue unexpected database queries with "IS NULL" where clauses.  This issue does *not* let an attacker insert arbitrary values into an SQL query, however they can cause the query to check for NULL where most users wouldn't expect it.

For example, a system has password reset with token functionality:

    unless params[:token].nil?
      user = User.find_by_token(params[:token])
      user.reset_password!
    end

An attacker can craft a request such that `params[:token]` will return `[nil]`.  The `[nil]` value will bypass the test for nil, but will still add an "IS NULL" clause to the SQL query.

All users running an affected release should either upgrade or use one of the work arounds immediately. 

CVE-2012-2661 Ruby on Rails Active Record SQL Injection Vulnerability

Impact
------
Due to the way Active Record handles nested query parameters, an attacker can use a specially crafted request to inject some forms of SQL into your application's SQL queries.

All users running an affected release should upgrade immediately.

Impacted code directly passes request params to the `where` method of an ActiveRecord class like this:

    Post.where(:id => params[:id]).all

An attacker can make a request that causes `params[:id]` to return a specially crafted hash that will cause the WHERE clause of the SQL statement to query an arbitrary table with some value.
Comment 1 Hans de Graaff gentoo-dev Security 2012-06-01 07:07:45 UTC
dev-ruby/rails-3.2.5 is now in the gentoo tree. I'll try to look at the older slots in the weekend.
Comment 2 Sean Amoss (RETIRED) gentoo-dev Security 2012-06-02 12:04:05 UTC
Thanks, Hans.

Rating as ~3 for now until it is confirmed whether or not 2.3.x is affected.
Comment 3 Hans de Graaff gentoo-dev Security 2012-06-02 13:56:45 UTC
(In reply to comment #2)
> Thanks, Hans.
> 
> Rating as ~3 for now until it is confirmed whether or not 2.3.x is affected.

2.3.x is not affected by the SQL injection since that is new code in 3.x. I can't determine if the other vulnerability applies to 2.3.x since the code is so extensively rewritten since. Note that upstream no longer security-supports 2.3.x...
Comment 4 Hans de Graaff gentoo-dev Security 2012-06-13 17:45:00 UTC
dev-ruby/rails-3.0.15 is now in the tree.
Comment 5 Tim Sammut (RETIRED) gentoo-dev 2012-06-16 23:10:17 UTC
Let's work in bug 420923. I think we just need a 3.1.x to fix both issues.
Comment 6 Sean Amoss (RETIRED) gentoo-dev Security 2012-07-10 21:32:54 UTC
Issue fixed with bug 420923. 

Thanks, everyone. 

Closing noglsa for ~arch only.
Comment 7 GLSAMaker/CVETool Bot gentoo-dev 2012-07-12 01:10:03 UTC
CVE-2012-2661 (http://nvd.nist.gov/nvd.cfm?cvename=CVE-2012-2661):
  The Active Record component in Ruby on Rails 3.0.x before 3.0.13, 3.1.x
  before 3.1.5, and 3.2.x before 3.2.4 does not properly implement the passing
  of request data to a where method in an ActiveRecord class, which allows
  remote attackers to conduct certain SQL injection attacks via nested query
  parameters that leverage unintended recursion, a related issue to
  CVE-2012-2695.

CVE-2012-2660 (http://nvd.nist.gov/nvd.cfm?cvename=CVE-2012-2660):
  actionpack/lib/action_dispatch/http/request.rb in Ruby on Rails before
  3.0.13, 3.1.x before 3.1.5, and 3.2.x before 3.2.4 does not properly
  consider differences in parameter handling between the Active Record
  component and the Rack interface, which allows remote attackers to bypass
  intended database-query restrictions and perform NULL checks via a crafted
  request, as demonstrated by certain "[nil]" values, a related issue to
  CVE-2012-2694.