Bug 766791 - VUL-0: rubygem-activerecord: Unsafe Query Generation (CVE-2012-2694)
VUL-0: rubygem-activerecord: Unsafe Query Generation (CVE-2012-2694)
Status: RESOLVED FIXED
Classification: Novell Products
Product: SUSE Security Incidents
Classification: Novell Products
Component: Incidents
unspecified
Other Other
: P3 - Medium : Normal
: ---
Assigned To: Security Team bot
Security Team bot
maint:released:sle11-sp1:48528 maint:...
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2012-06-13 07:38 UTC by Ludwig Nussel
Modified: 2013-01-29 15:30 UTC (History)
2 users (show)

See Also:
Found By: Other
Services Priority:
Business Priority:
Blocker: ---
Marketing QA Status: ---
IT Deployment: ---


Attachments
3-0-null_array_param.patch (1.89 KB, patch)
2012-06-13 07:44 UTC, Ludwig Nussel
Details | Diff
3-1-null_array_param.patch (1.89 KB, patch)
2012-06-13 07:45 UTC, Ludwig Nussel
Details | Diff
3-2-null_array_param.patch (1.89 KB, text/plain)
2012-06-13 07:45 UTC, Ludwig Nussel
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Ludwig Nussel 2012-06-13 07:38:08 UTC
Your friendly security team received the following report via oss-security.
Please respond ASAP.
The issue is public.

------------------------------------------------------------------------------
Date: Tue, 12 Jun 2012 14:29:08 -0700
From: Aaron Patterson <tenderlove@ruby-lang.org>
Subject: [oss-security] Ruby on Rails Unsafe Query Generation Risk in Ruby on Rails
 (CVE-2012-2694)

Unsafe Query Generation Risk in Ruby on Rails

There is a vulnerability when Active Record is used in conjunction with parameter parsing from Rack via Action Pack. This vulnerability has been assigned the CVE identifier CVE-2012-2694.

Versions Affected:  ALL versions
Not affected:       NONE
Fixed Versions:     3.2.6, 3.1.6, 3.0.14

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 `['xyz', nil]`.  The `['xyz', nil]` value will bypass the test for nil, but will still add an "IN ('xyz', NULL)" clause to the SQL query.

All users running an affected release should either upgrade or use one of the work arounds immediately. All users running an affected release should upgrade immediately. Please note, this vulnerability is a variant of CVE-2012-2660, even if you upgraded to address that issue, you must take action again.


Releases
-------- 
The FIXED releases are available at the normal locations. 

Workarounds
----------- 
This problem can be mitigated by casting the parameter to a sting before passing it to Active Record.  For example:

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

Note the parameter is still cast to a string before being send to Active Record.This is because an array with a nil value can still bypass the `to_s.empty?` test:

    >> ['xyz', nil].to_s
    => "xyz"
    >> ['xyz', nil].to_s.empty?
    => false

Patches 
------- 
To aid users who aren't able to upgrade immediately we have provided patches for the two supported release series.  They are in git-am format and consist of a single changeset. 

* 3-0-null_array_param.patch - Patch for 3.0 series 
* 3-1-null_array_param.patch - Patch for 3.1 series 
* 3-2-null_array_param.patch - Patch for 3.2 series 

Please note that only the 3.1.x and 3.2.x series are supported at present.  Users of earlier unsupported releases are advised to upgrade as soon as possible as we cannot guarantee the continued availability of security fixes for unsupported releases.

Credits 
------- 

Thanks to the following people for reporting this bug:

  * Egor Homakov
  * Paul Lynch

-- 
Aaron Patterson
http://tenderlovemaking.com/
Comment 1 Ludwig Nussel 2012-06-13 07:44:52 UTC
Created attachment 494608 [details]
3-0-null_array_param.patch
Comment 2 Ludwig Nussel 2012-06-13 07:45:07 UTC
Created attachment 494609 [details]
3-1-null_array_param.patch
Comment 3 Ludwig Nussel 2012-06-13 07:45:18 UTC
Created attachment 494610 [details]
3-2-null_array_param.patch
Comment 4 Swamp Workflow Management 2012-06-13 22:00:12 UTC
bugbot adjusting priority
Comment 5 Swamp Workflow Management 2012-08-21 12:07:02 UTC
Update released for: rubygem-actionpack-2_3
Products:
SLE-SDK 11-SP1 (i386, ia64, ppc64, s390x, x86_64)
SLE-WEBYAST 1.0-SP1 (i386, ia64, ppc64, s390x, x86_64)
Comment 6 Swamp Workflow Management 2012-08-21 13:55:22 UTC
Update released for: rubygem-actionpack-2_3
Products:
SLE-SDK 11-SP2 (i386, ia64, ppc64, s390x, x86_64)
Comment 7 Matthias Weckbecker 2012-08-24 13:51:14 UTC
released
Comment 8 Bernhard Wiedemann 2012-09-24 11:01:17 UTC
This is an autogenerated message for OBS integration:
This bug (766791) was mentioned in
https://build.opensuse.org/request/show/135624 Evergreen:11.2 / rubygem-actionpack-2_3
Comment 9 Swamp Workflow Management 2013-01-24 18:56:08 UTC
Update released for: hawk, hawk-debuginfo, hawk-debugsource, hawk-templates
Products:
SLE-HAE 11-SP2 (i386, ia64, ppc64, s390x, x86_64)
Comment 10 Swamp Workflow Management 2013-01-29 15:18:31 UTC
Update released for: rubygem-actionpack-2_3
Products:
SLE-SLMS 1.2 (x86_64)
SLE-STUDIOONSITE 1.2 (x86_64)
SLE-STUDIOONSITERUNNER 1.2 (s390x)
SLE-WEBYAST 1.2 (i386, ia64, ppc64, s390x, x86_64)
Comment 11 Swamp Workflow Management 2013-01-29 15:30:51 UTC
Update released for: rubygem-actionpack-2_3
Products:
SLE-SDK 11-SP2 (i386, ia64, ppc64, s390x, x86_64)
SUSE-CLOUD 1.0 (x86_64)