CVE-2026-26198·Python vulnerability
Ormar is a async mini ORM for Python. In versions 0.9.9 through 0.22.0, when performing aggregate queries, Ormar ORM constructs SQL expressions by passing user-supplied column names directly into `sqlalchemy.text()` without any validation or sanitization. The `min()` and `max()` methods in the `QuerySet` class accept arbitrary string input as the column parameter. While `sum()` and `avg()` are partially protected by an `is_numeric` type check that rejects non-existent fields, `min()` and `max()` skip this validation entirely. As a result, an attacker-controlled string is embedded as raw SQL inside the aggregate function call. Any unauthorized user can exploit this vulnerability to read the entire database contents, including tables unrelated to the queried model, by injecting a subquery as the column parameter. Version 0.23.0 contains a patch.
- Severity
- critical
- Software
- Python
- Fixed in
- 0.23.0
- Published
- 2026-02-24
Affected versions
From: 0.9.9
Until: 0.23.0
Fixed in: 0.23.0
How to fix this CVE
Update the Ormar ORM library to version 0.23.0 or later to patch SQL injection vulnerabilities in the min() and max() aggregate query methods. Applications using Ormar versions 0.9.9 through 0.22.0 should prioritize this upgrade immediately, as the vulnerability allows unauthenticated attackers to read arbitrary database contents through malicious column parameter injection.
sudo dnf update python3-ormar-0.23.0Defensia detects this vulnerability
What an exploitation attempt looks like
Sample log line indicative of exploitation attempts:
POST|GET request parameters containing SQL keywords (SELECT, UNION, WHERE, OR) passed to aggregate query endpoints; patterns like min(subquery) or max(CASE WHEN) in application logs; unusual database access to tables unrelated to the query contextWAF mitigation (if patching is not yet possible)
Add this rule to your WAF to block exploitation attempts while you schedule the patch.
Implement input validation rules that reject column parameter values containing SQL keywords (SELECT, UNION, CASE, WHEN, OR, AND). Block requests where min() or max() parameters contain parentheses or whitespace-delimited SQL fragments. Enforce allowlist validation against a predefined set of permitted column names at the application layer.How to check if you are affected
- Check installed Ormar version: python3 -c "import ormar; print(ormar.__version__)"
- Verify vulnerable code patterns: grep -r "QuerySet.*min(\|QuerySet.*max(" /path/to/application/code | grep -v "is_numeric" to identify unprotected aggregate calls
- Search application logs for SQL subqueries in aggregate parameters: grep -E "(min|max)\(.*SELECT|min|max.*WHERE.*=" /var/log/application.log
- Confirm patch installation: python3 -c "import ormar; assert ormar.__version__ >= '0.23.0', 'Vulnerable version detected'" && echo 'Patch verified' || echo 'Still vulnerable'
FAQ
What is CVE-2026-26198?
CVE-2026-26198 is a critical SQL injection vulnerability in Ormar ORM's min() and max() aggregate query methods that accept unsanitized user input as column names. An attacker can exploit this to execute arbitrary SQL queries and extract sensitive data from the entire database.
Is CVE-2026-26198 being actively exploited?
No, CVE-2026-26198 is not currently listed on the CISA Known Exploited Vulnerabilities catalog, and no public proof-of-concept exploits are available. However, the vulnerability is trivial to exploit and should be treated as a critical priority.
What versions of Python are affected by CVE-2026-26198?
CVE-2026-26198 affects the Ormar ORM library versions 0.9.9 through 0.22.0 regardless of Python version, as it is a library-level vulnerability. Python 3.6+ with vulnerable Ormar versions installed is at risk.
How do I check if my server is vulnerable to CVE-2026-26198?
Run 'python3 -c "import ormar; print(ormar.__version__)"' and verify the version is 0.23.0 or later. Additionally, audit your application code for direct use of min() and max() methods with user-supplied parameters.
Does Defensia detect CVE-2026-26198?
Yes — Defensia's CVE advisory scanner compares installed package versions against the NVD database. If Ormar is installed on a monitored server, CVE-2026-26198 will appear in your dashboard with remediation steps.
Related Python CVEs
References
Track CVEs across your fleet automatically
Defensia scans your Linux servers and tells you exactly which ones are running vulnerable versions — including CVE-2026-26198. Free for 1 server.
Get started free