# CVE-2023-22794: SQL Injection Vulnerability via ActiveRecord comments

- Severity: High 8.8 (CVSS:3.1, scored by NVD) `CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H`
- Known to be exploited: not in CISA's catalogue, which lists only what CISA has confirmed
- Likelihood of exploitation in the next 30 days (EPSS): 2.18%, higher than 82% of CVEs (2026-12-01)
- Public exploit code or proof of concept: one link below, marked "exploit"
- Published: 2023-01-18T18:20:19.000Z
- Modified: 2026-10-23T23:10:00.157Z
- Also known as: GHSA-hq7p-j377-6v63
- Weaknesses: CWE-89
- Assigned by: hackerone

## 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.

(As written by CVE List.)

## Affected

- https://github.com/rails/rails: 6.0.6.1, 6.1.7.1, 7.0.4.1
- activerecord (RubyGems): from 6.0.0 before 6.0.6.1; from 6.1.0 before 6.1.7.1; from 7.0.0 before 7.0.4.1
- activerecord_project activerecord: from 6.0.0 before 6.0.6.1; from 6.1.0 before 6.1.7.1; from 7.0.0 before 7.0.4.1

## Every score

- GitHub: CVSS:3.1 8.8 High `CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H`
- NVD: CVSS:3.1 8.8 High `CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H`

## References

- <https://discuss.rubyonrails.org/t/cve-2023-22794-sql-injection-vulnerability-via-activerecord-comments/82117> (exploit, patch, vendor-advisory, web)
- <https://www.debian.org/security/2023/dsa-5372> (vendor-advisory, web)
- <https://security.netapp.com/advisory/ntap-20240202-0008/>
- <https://nvd.nist.gov/vuln/detail/CVE-2023-22794> (advisory)
- <https://github.com/rails/rails/commit/d7aba06953f9fa789c411676b941d20df8ef73de> (web)
- <https://github.com/rails/rails> (package)
- <https://github.com/rails/rails/releases/tag/v7.0.4.1> (web)
- <https://github.com/rubysec/ruby-advisory-db/blob/master/gems/activerecord/CVE-2023-22794.yml> (web)
- <https://security.netapp.com/advisory/ntap-20240202-0008> (web)

## Sources

- CVE List: [CVE-2023-22794](https://www.cve.org/CVERecord?id=CVE-2023-22794), CVE Terms of Use, modified 2024-08-02
- GitHub Advisory Database: [GHSA-hq7p-j377-6v63](https://github.com/advisories/GHSA-hq7p-j377-6v63), CC-BY-4.0, modified 2024-02-21
- NVD: [CVE-2023-22794](https://nvd.nist.gov/vuln/detail/CVE-2023-22794), Public domain, modified 2026-10-23

---

Page: https://cve.day/CVE-2023-22794 · Whole record: https://cve.day/CVE-2023-22794.json · Rebuilt by cve.day 2026-11-25T22:58:21.905Z
