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

> Attackers can inject SQL via min/max aggregate functions to read entire database contents, affecting users of the Ormar Python ORM.

- **Severity:** Critical 9.8 (`CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H`)
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Over the internet
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 24 Feb 2026
- **Updated:** 24 Feb 2026
- **Also known as:** DEBIAN-CVE-2026-26198, GHSA-xxh2-68g9-8jqr, PYSEC-2026-439, UBUNTU-CVE-2026-26198

## What is CVE-2026-26198?

CVE-2026-26198 is a critical SQL injection vulnerability in collerek ormar, published on 24 Feb 2026. An attacker can exploit it over the internet without logging in, with no action from the victim.

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

Weakness: CWE-89 (Improper Neutralization of Special Elements used in an SQL Command)

## Which versions are affected by CVE-2026-26198?

3 open source packages ship an affected version, including ormar. It affects 1 product.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `ormar` | PyPI | From 0.9.9 | 0.23.0 |
| `ormar` | PyPI | From 0.9.9 | 0.23.0 |
| `ormar` | PyPI | From 0.9.9 | 0.23.0 |

Products: Collerek Ormar.

## How do I fix CVE-2026-26198?

Upgrade ormar to 0.23.0 or later.

## Is CVE-2026-26198 being exploited?

It is not confirmed as exploited in the wild, but public exploit code for CVE-2026-26198 exists.

Public exploit code:

- Deep dive into a critical SQL injection in Python's Ormar ORM — reproduction, fix, and tests (github_poc): https://github.com/sergicortesabadia/CVE-2026-26198-analysis
- https://github.com/NetVanguard-cmd/CVE-2026-26198 (github_poc): https://github.com/NetVanguard-cmd/CVE-2026-26198

## Other vulnerabilities in collerek ormar

- [CVE-2026-27953](https://insights.sbomify.com/CVE-2026-27953/): ormar has a Pydantic Validation Bypass via Kwargs Injection in Model Constructor (high 7.1)

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2026-26198 and fix it if it is affected.

What it is: CVE-2026-26198 is a critical SQL injection vulnerability in collerek ormar, published on 24 Feb 2026. An attacker can exploit it over the internet without logging in, with no action from the victim.
Exploitation: It is not confirmed as exploited in the wild, but public exploit code for CVE-2026-26198 exists.

Affected packages and fixed versions:
- ormar (PyPI): affected from 0.9.9; fixed in 0.23.0
- ormar (PyPI): affected from 0.9.9; fixed in 0.23.0
- ormar (PyPI): affected from 0.9.9; fixed in 0.23.0

Task:
1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.
2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.
3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.
4. Run the tests and summarise what changed and why.
5. If nothing in the project is affected, say so and change nothing.

Reference: https://insights.sbomify.com/CVE-2026-26198/ (Markdown: https://insights.sbomify.com/CVE-2026-26198/index.md)
```

## Sources

- CVE record: https://www.cve.org/CVERecord?id=CVE-2026-26198
- NVD: https://nvd.nist.gov/vuln/detail/CVE-2026-26198
- OSV: https://osv.dev/vulnerability/CVE-2026-26198

---
From sbomify Insights: https://insights.sbomify.com/CVE-2026-26198/
Summaries are generated and may contain mistakes; the official description above is the record.
