Summary
A SQL injection vulnerability in Drogon's ORM criteria-building logic may allow attacker-controlled filter input to alter generated database queries. Because the vulnerable path can be reached remotely in applications that expose affected functionality, attackers could access, modify, or disrupt data depending on database permissions.
Affected context
The issue occurs in applications using Drogon's ORM component and the makeCriteria function to construct database criteria from externally influenced filter values. Risk is higher when remote requests can reach this functionality and application input is incorporated into query expressions without sufficient parameterization or constrained query construction.
Exploit preconditions
- Attack surface: A remotely reachable application endpoint or service that uses Drogon's ORM filtering functionality
- Required access: Ability to submit or influence filter-related request parameters; authentication requirements depend on the application's access controls
- Trigger point: Processing attacker-controlled input through
makeCriteriain the ORM component - Why exploitation is possible: Untrusted filter data may influence SQL query structure rather than being handled solely as parameter values
Why this happens
The underlying bug is improper separation between data and SQL command structure during ORM criteria construction. When externally controlled filter input is incorporated into query expressions without robust parameter binding, an attacker may inject SQL syntax into the resulting statement. This maps primarily to CWE-89: Improper Neutralization of Special Elements used in an SQL Command (SQL Injection) and is also related to CWE-74: Improper Neutralization of Special Elements in Output Used by a Downstream Component.
Potential impact
- An attacker may read unauthorized database records
- An attacker could alter or delete application data
- Crafted queries may cause database errors or service disruption
- Database credentials or connected systems may be exposed depending on permissions
- Successful exploitation could support further compromise of the application environment
General mitigation guidance
Mitigation generally focuses on preserving a strict boundary between query structure and user-controlled values.
Common defensive patterns include:
- Using parameterized queries and bound ORM values for externally supplied data
- Allowing only explicitly supported fields, operators, and sort directions through an allowlist
- Avoiding direct concatenation of request data into SQL fragments
- Applying consistent input validation before criteria construction
- Restricting database accounts to the minimum permissions required by the application
- Separating read and write database identities where practical
- Enforcing authentication, authorization, and rate limits on query-bearing endpoints
How teams detect issues like this
Organizations can look for this weakness through:
- Static analysis rules identifying string concatenation or interpolation near SQL and ORM query builders
- Code review checks for criteria APIs that accept raw expressions or unrestricted filter names and operators
- Runtime monitoring for anomalous query syntax, unexpected database errors, and unusual read or write patterns
- Tests that verify externally supplied values remain bound parameters rather than query structure
- Policy enforcement requiring approved query-builder abstractions and parameterization patterns
- Neutral automated review tools that flag potential CWE-74 and CWE-89 data-flow paths

