CVE-2023-22794 SQL Injection Vulnerability via ActiveRecord comments

High 8.8 Published Updated

Insufficient sanitization in ActiveRecord allows SQL injection via malicious input in query annotations or optimizer hints.

Exploited in the wild
Not known
Login needed
Any signed-in user
Attackable
Over the internet
Victim action needed
Not needed
Fix
Available

What is CVE-2023-22794?

CVE-2023-22794 is a high-severity SQL injection vulnerability in https://github.com/rails/rails, published on 9 Feb 2023. Any signed-in user can exploit it over the network, with no action from the victim.

Official description

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 `optimizer_hints` 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.

Weakness: CWE-89

Which versions are affected by CVE-2023-22794?

6 open source packages ship an affected version, including activerecord. It affects 1 product.

PackageAffectedFixed in
activerecord RubyGemsFrom 6.0.06.0.6.1
activerecord RubyGemsFrom 6.0.06.0.6.1
activerecord RubyGemsFrom 6.1.06.1.7.1
activerecord RubyGemsFrom 6.1.06.1.7.1
activerecord RubyGemsFrom 7.0.07.0.4.1
activerecord RubyGemsFrom 7.0.07.0.4.1

Products include Activerecord Project Activerecord.

How do I fix CVE-2023-22794?

Upgrade activerecord to a fixed version for your release line: 6.0.6.1, 6.1.7.1 or 7.0.4.1.

Use parameterised queries everywhere and never build SQL by joining strings. Upgrade affected software first; a web application firewall only buys time. More about SQL injection.

Is CVE-2023-22794 being exploited?

There is no known exploitation of CVE-2023-22794 in the wild and no public exploit code.

Sources

Also known as DEBIAN-CVE-2023-22794, GHSA-hq7p-j377-6v63, UBUNTU-CVE-2023-22794.

Is CVE-2023-22794 in your software?

Upload an SBOM and sbomify checks it against every vulnerability here, every day.

Check your SBOMs for free