Impact
Ormar is a lightweight asynchronous ORM for Python. In versions 0.9.9 through 0.22.0 aggregate queries reconstruct SQL by inserting the user‑supplied column name directly into the SQL expression via sqlalchemy.text() without validation. The min() and max() functions accept arbitrary strings as the column parameter and perform no type checking, unlike sum() or avg(). As a result, an attacker can inject a subquery or complex expression into the aggregate function, which is executed by the database engine. This flaw allows anyone who can submit a query to read arbitrary database tables, thereby compromising data confidentiality and integrity for the entire database.
Affected Systems
The vulnerability affects the Collerek Ormar library, versions 0.9.9 through 0.22.0. A fix was introduced in release 0.23.0. This includes all Python implementations that use Ormar for database interaction under the cited version range.
Risk and Exploitability
The CVSS score of 9.8 indicates critical severity for unauthenticated or low‑privileged attackers. The EPSS score of less than 1% implies a low overall exploitation probability at present, but the fact that the code paths are exposed through application APIs means that exploitation could occur via normal user interaction. The vulnerability is not listed in the CISA Known Exploited Vulnerabilities catalog, so no publicly known exploits have been documented yet. An attacker who can manipulate the column parameter—e.g., via a public API endpoint—can craft an input that introduces a subquery, retrieve all rows from unrelated tables, or exfiltrate sensitive data. The absence of input validation in min() and max() means the attack can succeed without additional credentials beyond whatever the application permits.
OpenCVE Enrichment
Github GHSA