CVE-2012-6497
Description
The Authlogic gem for Ruby on Rails, when used with certain versions before 3.2.10, makes potentially unsafe find_by_id method calls, which might allow remote attackers to conduct CVE-2012-6496 SQL injection attacks via a crafted parameter in environments that have a known secret_token value, as demonstrated by a value contained in secret_token.rb in an open-source product.
AI Insight
LLM-synthesized narrative grounded in this CVE's description and references.
Authlogic gem < 3.2.10 calls unsafe find_by_id, enabling SQL injection via crafted params when the secret_token is known.
Vulnerability
The Authlogic gem for Ruby on Rails, prior to version 3.2.10, makes potentially unsafe find_by_id method calls. In environments where the application's secret_token value is known (e.g., exposed in open-source secret_token.rb files), remote attackers can craft malicious parameters to perform SQL injection attacks. The issue is directly related to CVE-2012-6496 and allows exploitation when the secret token allows session tampering [1] [2].
Exploitation
An attacker needs knowledge of the application's secret_token value. With this token, the attacker can forge a session cookie that injects a crafted parameter (such as id[] or similar) into the call chain. When Authlogic uses the forged session data to call find_by_id, the malicious parameter leads to SQL injection. The exploitation requires no authentication, as the session cookie is manipulated externally [3] [4].
Impact
Successful exploitation allows remote attackers to execute arbitrary SQL queries against the database. This can result in unauthorized access to sensitive data, data modification, or complete compromise of the database. The attacker gains the ability to read or write any database record, potentially escalating to broader system control [1] [2].
Mitigation
Users should upgrade to Authlogic gem version 3.2.10 or later, which addresses unsafe find_by_id calls by properly sanitizing inputs. The fix was released in early 2013. As a general best practice, secret tokens should not be exposed in public code repositories or open-source products [1] [4]. No workaround other than upgrading is recommended.
AI Insight generated on May 23, 2026. Synthesized from this CVE's description and the cited reference URLs; citations are validated against the source bundle.
Affected packages
Versions sourced from the GitHub Security Advisory.
| Package | Affected versions | Patched versions |
|---|---|---|
authlogicRubyGems | < 3.3.0 | 3.3.0 |
Affected products
3Patches
11d57a6c4abe4Fix session persistence sql vulnerabilities
2 files changed · +20 −2
lib/authlogic/session/session.rb+2 −2 modified@@ -35,8 +35,8 @@ def persist_by_session # Allow finding by persistence token, because when records are created the session is maintained in a before_save, when there is no id. # This is done for performance reasons and to save on queries. record = record_id.nil? ? - search_for_record("find_by_persistence_token", persistence_token) : - search_for_record("find_by_#{klass.primary_key}", record_id) + search_for_record("find_by_persistence_token", persistence_token.to_s) : + search_for_record("find_by_#{klass.primary_key}", record_id.to_s) self.unauthorized_record = record if record && record.persistence_token == persistence_token valid? else
test/session_test/session_test.rb+18 −0 modified@@ -20,6 +20,24 @@ def test_persist_persist_by_session assert_equal ben, session.record assert_equal ben.persistence_token, controller.session["user_credentials"] end + + def test_persist_persist_by_session_with_session_fixation_attack + ben = users(:ben) + controller.session["user_credentials"] = 'neo' + controller.session["user_credentials_id"] = {:select => " *,'neo' AS persistence_token FROM users WHERE id = #{ben.id} limit 1 -- "} + @user_session = UserSession.find + assert @user_session.blank? + end + + def test_persist_persist_by_session_with_sql_injection_attack + ben = users(:ben) + controller.session["user_credentials"] = {:select => "ABRA CADABRA"} + controller.session["user_credentials_id"] = nil + assert_nothing_raised do + @user_session = UserSession.find + end + assert @user_session.blank? + end def test_persist_persist_by_session_with_token_only ben = users(:ben)
Vulnerability mechanics
Generated on May 9, 2026. Inputs: CWE entries + fix-commit diffs from this CVE's patches. Citations validated against bundle.
References
11- blog.phusion.nl/2013/01/03/rails-sql-injection-vulnerability-hold-your-horses-here-are-the-facts/nvdExploit
- phenoelit.org/blog/archives/2012/12/21/let_me_github_that_for_you/index.htmlnvdBroken LinkExploit
- openwall.com/lists/oss-security/2013/01/03/12nvdMailing ListThird Party AdvisoryWEB
- www.securityfocus.com/bid/57084nvdBroken LinkThird Party AdvisoryVDB Entry
- github.com/advisories/GHSA-rx7j-mw4c-76g9ghsaADVISORY
- nvd.nist.gov/vuln/detail/CVE-2012-6497ghsaADVISORY
- blog.phusion.nl/2013/01/03/rails-sql-injection-vulnerability-hold-your-horses-here-are-the-factsghsaWEB
- github.com/binarylogic/authlogic/commit/1d57a6c4abe43a3c0b4ef578486ea00e1f7a9873ghsaWEB
- github.com/binarylogic/authlogic/pull/341ghsaWEB
- web.archive.org/web/20130104161608/http://www.securityfocus.com/bid/57084ghsaWEB
- web.archive.org/web/20130116043311/http://phenoelit.org/blog/archives/2012/12/21/let_me_github_that_for_you/index.htmlghsaWEB
News mentions
0No linked articles in our index yet.