ADVISORIES
GEM
FRAMEWORK
SEVERITY
CVSS v3.x: 8.8 (High)
UNAFFECTED VERSIONS
- < 6.0.0
PATCHED VERSIONS
- ~> 6.0.6, >= 6.0.6.1
- ~> 6.1.7, >= 6.1.7.1
- >= 7.0.4.1
DESCRIPTION
There is a possible vulnerability in ActiveRecord related to the sanitization of comments. This vulnerability has been assigned the CVE identifier CVE-2023-22794.
Versions Affected: >= 6.0.0 Not affected: < 6.0.0 Fixed Versions: 6.0.6.1, 6.1.7.1, 7.0.4.1
Impact
Previously the implementation of escaping for comments was insufficient for
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 with insufficient sanitization and be able to inject SQL outside of the comment.
In most cases these interfaces won’t be used with user input and users should avoid doing so.
Example vulnerable code:
Post.where(id: 1).annotate("#{params[:user_input]}")
Post.where(id: 1).optimizer_hints("#{params[:user_input]}")
Example vulnerable QueryLogs configuration (the default configuration is not vulnerable):
config.active_record.query_log_tags = [
{
something: -> { <some value including user input> }
}
]
All users running an affected release should either upgrade or use one of the workarounds immediately.
Workarounds
Avoid passing user input to annotate and avoid using QueryLogs configuration which can include user input.