Critical (9.8)

CVE-2026-26198: Python

CVE-2026-26198

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 `sql...

Affected: Python

Overview

A critical security vulnerability has been identified in the Ormar library, a popular asynchronous ORM (Object-Relational Mapper) for Python. This flaw allows an attacker to execute arbitrary SQL commands, potentially leading to a full compromise of the connected database.

Vulnerability Explained Simply

Ormar helps developers interact with databases using Python code instead of raw SQL. In affected versions, two specific functions-min() and max()-fail to properly check the user-supplied column names used in queries. Because these inputs are not validated, an attacker can craft a malicious string that gets interpreted as part of a SQL command. This allows them to inject their own SQL code, effectively bypassing the ORM’s safety controls and interacting directly with the database.

Potential Impact

The impact of this vulnerability is severe. An unauthorized user can exploit it to:

  • Read all data from the database, including sensitive information from tables not normally accessible to the application.
  • Exfiltrate user credentials, personal data, financial records, or any other stored information.
  • Perform data manipulation such as altering or deleting data, depending on database permissions.

Given that exploitation requires no special privileges and can be performed remotely, this vulnerability poses a significant risk to any application using a vulnerable version of Ormar.

Remediation and Mitigation

Immediate action is required to secure affected systems.

Primary Fix: The issue is patched in Ormar version 0.23.0. All users of versions 0.9.9 through 0.22.0 must upgrade immediately.

pip install --upgrade ormar==0.23.0

Temporary Mitigation (If Immediate Upgrade is Not Possible): If an upgrade cannot be performed instantly, developers must implement strict input validation on any application code that uses the QuerySet.min() or QuerySet.max() methods with user-provided data. Ensure only pre-approved, whitelisted column names are passed to these methods. This is a stopgap measure; upgrading remains the only complete solution.

Verification: After upgrading, review your codebase for any usage of aggregate functions (min, max, sum, avg) and confirm they are not accepting unsanitized user input. Conduct thorough testing to ensure application functionality remains correct.

Share:

Never miss a critical vulnerability

Get real-time security alerts delivered to your preferred platform.

Am I Affected by CVE-2026-26198?

Pick an ecosystem, paste your installed version, and we'll compare it against the fixed version published on OSV.dev. Browser-only — nothing is sent to a server.

Heuristic comparison only. Always cross-check against the vendor advisory before making patching decisions.

Related Advisories

Other Python Vulnerabilities

View all Python vulnerabilities →

Never Miss a Critical Alert

CVE advisories, breach reports, and threat intel — delivered daily to your inbox.