7.5
CWE
89
Advisory Published
CVE Published
Advisory Published
Updated

CVE-2012-2695: SQL Injection

First published: Wed Jun 13 2012(Updated: )

Originally, the <a href="https://access.redhat.com/security/cve/CVE-2012-2661">CVE-2012-2661</a> identifier has been assigned to the following issue: A security flaw was found in the way rubygem-activerecord, the ActiveRecord pattern for ORM, performed SQL query generation based on the content of params hash, when nested query paramaters were provided. If a Ruby on Rails application directly passed request params to the 'where' method of an ActiveRecord class, a remote attacker could use this flaw to cause the 'params[:id]' to return a specially-crafted hash, resulting into the WHERE clause of the SQL statement to query an arbitrary table with value of attacker's choice, leading to disclosure of sensitive information. (<a class="bz_bug_link bz_status_CLOSED bz_closed bz_public " title="CLOSED ERRATA - CVE-2012-2661 rubygem-activerecord: SQL injection when processing nested query paramaters" href="show_bug.cgi?id=827363">bug 827363</a>) Recently (2012-06-12) it has been reported: [1] <a href="https://groups.google.com/group/rubyonrails-security/browse_thread/thread/9782f44c4540cf59">https://groups.google.com/group/rubyonrails-security/browse_thread/thread/9782f44c4540cf59</a> that there still exists a variant of this attack, which is possible to exploit even when the upstream patch for the original <a href="https://access.redhat.com/security/cve/CVE-2012-2661">CVE-2012-2661</a> issue has been applied. More from [1]: -- 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. Please note, this vulnerability is a variant of <a href="https://access.redhat.com/security/cve/CVE-2012-2661">CVE-2012-2661</a>, even if you upgraded to address that issue, you must take action again. Impacted code directly passes request params to the `where` method of an ActiveRecord class like this: Post.where(:id =&gt; 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. -- Proposed upstream patches (see attachments).

Credit: secalert@redhat.com

Affected SoftwareAffected VersionHow to fix
redhat/rubygem-activerecord<3.2.6
3.2.6
redhat/rubygem-activerecord<3.1.6
3.1.6
redhat/rubygem-activerecord<3.0.14
3.0.14
rubygems/activerecord<2.3.15
2.3.15
rubygems/activerecord>=3.0.0.beta<3.0.14
3.0.14
rubygems/activerecord>=3.2.0<3.2.6
3.2.6
rubygems/activerecord>=3.1.0<3.1.6
3.1.6
Ruby on Rails=3.0.0
Ruby on Rails=3.0.0-beta
Ruby on Rails=3.0.0-beta2
Ruby on Rails=3.0.0-beta3
Ruby on Rails=3.0.0-beta4
Ruby on Rails=3.0.0-rc
Ruby on Rails=3.0.0-rc2
Ruby on Rails=3.0.1
Ruby on Rails=3.0.1-pre
Ruby on Rails=3.0.2
Ruby on Rails=3.0.2-pre
Ruby on Rails=3.0.3
Ruby on Rails=3.0.4-rc1
Ruby on Rails=3.0.5
Ruby on Rails=3.0.5-rc1
Ruby on Rails=3.0.6
Ruby on Rails=3.0.6-rc1
Ruby on Rails=3.0.6-rc2
Ruby on Rails=3.0.7
Ruby on Rails=3.0.7-rc1
Ruby on Rails=3.0.7-rc2
Ruby on Rails=3.0.8
Ruby on Rails=3.0.8-rc1
Ruby on Rails=3.0.8-rc2
Ruby on Rails=3.0.8-rc3
Ruby on Rails=3.0.8-rc4
Ruby on Rails=3.0.9
Ruby on Rails=3.0.9-rc1
Ruby on Rails=3.0.9-rc2
Ruby on Rails=3.0.9-rc3
Ruby on Rails=3.0.9-rc4
Ruby on Rails=3.0.9-rc5
Ruby on Rails=3.0.10
Ruby on Rails=3.0.10-rc1
Ruby on Rails=3.0.11
Ruby on Rails=3.0.12
Ruby on Rails=3.0.12-rc1
Ruby on Rails=3.0.13-rc1
Ruby on Rails<=3.0.13
Ruby on Rails=3.0.4
Ruby on Rails=3.1.0
Ruby on Rails=3.1.0-beta1
Ruby on Rails=3.1.0-rc1
Ruby on Rails=3.1.0-rc2
Ruby on Rails=3.1.0-rc3
Ruby on Rails=3.1.0-rc4
Ruby on Rails=3.1.0-rc5
Ruby on Rails=3.1.0-rc6
Ruby on Rails=3.1.0-rc7
Ruby on Rails=3.1.0-rc8
Ruby on Rails=3.1.1
Ruby on Rails=3.1.1-rc1
Ruby on Rails=3.1.1-rc2
Ruby on Rails=3.1.1-rc3
Ruby on Rails=3.1.2
Ruby on Rails=3.1.2-rc1
Ruby on Rails=3.1.2-rc2
Ruby on Rails=3.1.3
Ruby on Rails=3.1.4
Ruby on Rails=3.1.4-rc1
Ruby on Rails=3.1.5
Ruby on Rails=3.1.5-rc1
Ruby on Rails=3.2.0
Ruby on Rails=3.2.0-rc1
Ruby on Rails=3.2.0-rc2
Ruby on Rails=3.2.1
Ruby on Rails=3.2.2
Ruby on Rails=3.2.2-rc1
Ruby on Rails=3.2.3
Ruby on Rails=3.2.3-rc1
Ruby on Rails=3.2.3-rc2
Ruby on Rails=3.2.4
Ruby on Rails=3.2.4-rc1
Ruby on Rails=3.2.5

Never miss a vulnerability like this again

Sign up to SecAlerts for real-time vulnerability data matched to your software, aggregated from hundreds of sources.

Reference Links

Frequently Asked Questions

  • What are the affected versions for CVE-2012-2695?

    Affected versions include rubygem-activerecord up to 3.2.6, 3.1.6, and 3.0.14, as well as activerecord versions up to 2.3.15.

  • What is the nature of the vulnerability described in CVE-2012-2695?

    CVE-2012-2695 is a security flaw in the way rubygem-activerecord handled SQL query generation.

  • How do I fix CVE-2012-2695?

    To fix CVE-2012-2695, upgrade rubygem-activerecord to version 3.2.6, 3.1.6, or 3.0.14.

  • What are the potential impacts of CVE-2012-2695?

    The vulnerability could allow malicious actors to manipulate SQL queries, potentially leading to unauthorized access to data.

  • Is there a patch available for CVE-2012-2695?

    Yes, patches are available in the form of upgraded versions of rubygem-activerecord and activerecord.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2025 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203