CVE-2023-22794: SQL Injection

Published Jan 18, 2023
·
Updated

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

10 affected componentsFixes available
rubygems/activerecord>=7.0.0<7.0.4.1
7.0.4.1
rubygems/activerecord>=6.1.0<6.1.7.1
6.1.7.1
rubygems/activerecord>=6.0.0<6.0.6.1
6.0.6.1
Activerecord Project Activerecord Ruby>=6.0.0<6.0.6.1
Activerecord Project Activerecord Ruby>=6.1.0<6.1.7.1
Activerecord Project Activerecord Ruby>=7.0.0<7.0.4.1
redhat/rubygem-activerecord<6.0.6.1
6.0.6.1
redhat/rubygem-activerecord<6.1.7.1
6.1.7.1
redhat/rubygem-activerecord<7.0.4.1
7.0.4.1
debian/rails
2:6.1.7.10+dfsg-1~deb12u22:6.1.7.10+dfsg-1~deb12u32:7.2.2.2+dfsg-2~deb13u12:7.2.2.2+dfsg-2~deb13u22:7.2.4+dfsg-12:7.2.4+dfsg-2

Remediation

Recommended actions to resolve this vulnerability, in priority order.

  1. Upgrade

    Upgrade rubygems/activerecord to a version that resolves this vulnerability.

    Fixed in 7.0.4.1
  2. Upgrade

    Upgrade rubygems/activerecord to a version that resolves this vulnerability.

    Fixed in 6.1.7.1
  3. Upgrade

    Upgrade rubygems/activerecord to a version that resolves this vulnerability.

    Fixed in 6.0.6.1
  4. Upgrade

    Upgrade redhat/rubygem-activerecord to a version that resolves this vulnerability.

    Fixed in 6.0.6.1
  5. Upgrade

    Upgrade redhat/rubygem-activerecord to a version that resolves this vulnerability.

    Fixed in 6.1.7.1
  6. Upgrade

    Upgrade redhat/rubygem-activerecord to a version that resolves this vulnerability.

    Fixed in 7.0.4.1
  7. Upgrade

    Upgrade debian/rails to 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
  8. Upgrade

    Upgrade ActiveRecord to a version that resolves this vulnerability.

    Fixed in 6.0.6.1Patch 6-0-Make-sanitize_as_sql_comment-more-strict.patch
  9. Upgrade

    Upgrade ActiveRecord to a version that resolves this vulnerability.

    Fixed in 6.1.7.1Patch 6-1-Make-sanitize_as_sql_comment-more-strict.patch
  10. Upgrade

    Upgrade ActiveRecord to a version that resolves this vulnerability.

    Fixed in 7.0.4.1Patch 7-0-Make-sanitize_as_sql_comment-more-strict.patch
  11. 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

Jan 18, 2023
Advisory Published
via GitHub·06:20 PM
Jan 26, 2023
Data Sourced
via Red Hat·01:57 PM
DescriptionSeverityAffected Software
Feb 9, 2023
CVE Published
via MITRE·12:00 AM
Data Sourced
via MITRE·12:00 AM
DescriptionWeakness
Data Sourced
via NVD·08:15 PM
RemedyDescriptionSeverityWeaknessAffected Software

Parent advisories

This vulnerability appears in the following advisories.

Frequently Asked Questions

1

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.

2

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.

3

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.

4

How can I fix the CVE-2023-22794 vulnerability?

Apply the appropriate patches or updates recommended by the Debian Rails security advisory.

5

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

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.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203