CVE-2023-22794: SQL Injection
A vulnerability in ActiveRecord <6.0.6.1, v6.1.7.1 and v7.0.4.1 related to the sanitization of comments. If malicious user input is passed to either the annotate query method, the optimizerhints query method, or through the QueryLogs interface which automatically adds annotations, it may be sent to the database withinsufficient sanitization and be able to inject SQL outside of the comment.
Other sources
If malicious user input is passed to either the annotate query method, the optimizerhints query method, or through the QueryLogs interface which automatically adds annotations, it may be sent to the database with insufficient sanitization and be able to inject SQL outside of the comment.
— Red Hat
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
rubygems/activerecordto a version that resolves this vulnerability.Fixed in 7.0.4.1 - Upgrade
Upgrade
rubygems/activerecordto a version that resolves this vulnerability.Fixed in 6.1.7.1 - Upgrade
Upgrade
rubygems/activerecordto a version that resolves this vulnerability.Fixed in 6.0.6.1 - Upgrade
Upgrade
redhat/rubygem-activerecordto a version that resolves this vulnerability.Fixed in 6.0.6.1 - Upgrade
Upgrade
redhat/rubygem-activerecordto a version that resolves this vulnerability.Fixed in 6.1.7.1 - Upgrade
Upgrade
redhat/rubygem-activerecordto a version that resolves this vulnerability.Fixed in 7.0.4.1 - Upgrade
Upgrade
debian/railsto a version that resolves this vulnerability.Fixed in 2:6.1.7.10+dfsg-1~deb12u2Fixed in 2:6.1.7.10+dfsg-1~deb12u3Fixed in 2:7.2.2.2+dfsg-2~deb13u1Fixed in 2:7.2.2.2+dfsg-2~deb13u2Fixed in 2:7.2.4+dfsg-1Fixed in 2:7.2.4+dfsg-2 - Upgrade
Upgrade
ActiveRecordto a version that resolves this vulnerability.Fixed in 6.0.6.1Patch 6-0-Make-sanitize_as_sql_comment-more-strict.patch - Upgrade
Upgrade
ActiveRecordto a version that resolves this vulnerability.Fixed in 6.1.7.1Patch 6-1-Make-sanitize_as_sql_comment-more-strict.patch - Upgrade
Upgrade
ActiveRecordto a version that resolves this vulnerability.Fixed in 7.0.4.1Patch 7-0-Make-sanitize_as_sql_comment-more-strict.patch - Compensating control
Avoid passing user input to ActiveRecord's annotate or optimizer_hints query methods, and avoid using QueryLogs configuration, including active_record.query_log_tags, with values that include user input.
Event History
Frequently Asked Questions
What is the vulnerability CVE-2023-22794?
CVE-2023-22794 is a vulnerability in ActiveRecord <6.0.6.1, v6.1.7.1, and v7.0.4.1 related to the sanitization of comments.
How can the CVE-2023-22794 vulnerability be exploited?
If malicious user input is passed to either the `annotate` query method, the `optimizer_hints` query method, or through the QueryLogs interface which automatically adds annotations, it may be exploited.
Which versions of Rails are affected by CVE-2023-22794 vulnerability?
Versions 2:5.2.2.1+dfsg-1+deb10u3, 2:5.2.2.1+dfsg-1+deb10u5, 2:6.0.3.7+dfsg-2+deb11u2, 2:6.1.7.3+dfsg-1, and 2:6.1.7.3+dfsg-2 of Rails are affected.
How can I fix the CVE-2023-22794 vulnerability?
Apply the appropriate patches or updates recommended by the Debian Rails security advisory.
Where can I find more information about the CVE-2023-22794 vulnerability?
More information can be found at the following references: [1] https://discuss.rubyonrails.org/t/cve-2023-22794-sql-injection-vulnerability-via-activerecord-comments/82117 [2] https://github.com/rails/rails/commit/048e9fc05e18c91838a44e60175e475de8b2aad5 [3] https://security-tracker.debian.org/tracker/CVE-2023-22794