CVE-2012-2661: Activerecord SQL Injection Vulnerability
MODERATECVE-2012-2661 is a MODERATE sql injection vulnerability (CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')) affecting Activerecord libraries in the RubyGems ecosystem. The issue involves active record vulnerable to sql injection via nested query parameters. Remediation is available by upgrading affected packages to version 3.0.13, 3.1.5, 3.2.4.
CVE-2012-2661 at a Glance
How to Fix CVE-2012-2661
To remediate this vulnerability, upgrade all affected Activerecord dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.
Upgrade activerecord to 3.0.13
Upgrade activerecord to 3.1.5
Upgrade activerecord to 3.2.4
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
inspect dependencies for activerecord
How to Check if You Are Affected
To determine whether your application is affected by CVE-2012-2661, inspect your project dependencies for Activerecord:
inspect dependencies for activerecord
Analyze the terminal output to locate any version of Activerecord in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 3.0.13), your application is affected.
Note: Verify declared build manifests and deployed runtime container environments.
Technical Details
Vulnerability Mechanism & Technical Analysis
This vulnerability is classified under CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection'), where the product constructs all or part of an sql command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended sql command when it is sent to a downstream component. without sufficient removal or quoting of sql syntax in user-controllable inputs, the generated sql query can cause those inputs to be interpreted as sql instead of ordinary user data. In Activerecord, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.
Source Advisory Statement
CVE-2012-2661 Affected Activerecord Versions
3 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
activerecord
|
RubyGems |
≥ 3.0.0
< 3.0.13
|
3.0.13
|
|
activerecord
|
RubyGems |
≥ 3.1.0
< 3.1.5
|
3.1.5
|
|
activerecord
|
RubyGems |
≥ 3.2.0
< 3.2.4
|
3.2.4
|
References
Frequently Asked Questions
What is CVE-2012-2661?
Which Activerecord versions are affected?
What version fixes CVE-2012-2661?
Is activerecord affected?
What CWE is associated with CVE-2012-2661?
How can I check RubyGems dependencies for CVE-2012-2661?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-fh39-v733-mxfr",
"modified" : "2023-03-14T22:18:13Z",
"published" : "2017-10-24T18:33:38Z",
"aliases" : [ "CVE-2012-2661" ],
"summary" : "Active Record vulnerable to SQL Injection via nested query parameters",
"details" : "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.",
"severity" : [ ],
"affected" : [ {
"package" : {
"ecosystem" : "RubyGems",
"name" : "activerecord"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "3.0.0"
}, {
"fixed" : "3.0.13"
} ]
} ]
}, {
"package" : {
"ecosystem" : "RubyGems",
"name" : "activerecord"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "3.1.0"
}, {
"fixed" : "3.1.5"
} ]
} ]
}, {
"package" : {
"ecosystem" : "RubyGems",
"name" : "activerecord"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "3.2.0"
}, {
"fixed" : "3.2.4"
} ]
} ]
} ],
"references" : [ {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2012-2661"
}, {
"type" : "WEB",
"url" : "https://groups.google.com/group/rubyonrails-security/msg/fc2da6c627fc92df?dmode=source&output=gplain"
}, {
"type" : "WEB",
"url" : "http://lists.opensuse.org/opensuse-security-announce/2012-08/msg00014.html"
}, {
"type" : "WEB",
"url" : "http://lists.opensuse.org/opensuse-security-announce/2012-08/msg00016.html"
}, {
"type" : "WEB",
"url" : "http://lists.opensuse.org/opensuse-updates/2012-08/msg00046.html"
}, {
"type" : "WEB",
"url" : "http://rhn.redhat.com/errata/RHSA-2013-0154.html"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-89" ],
"severity" : "MODERATE",
"github_reviewed" : true,
"github_reviewed_at" : "2020-06-16T21:34:40Z",
"nvd_published_at" : "2012-06-22T14:55:01Z"
}
}