Summary
A SQL injection vulnerability in Fleet's handling of the order_key query parameter allowed authenticated users to inject arbitrary SQL expressions into an ORDER BY clause.
By abusing unsafe use of goqu.I() during query construction, an attacker who can reach the affected endpoint could perform blind SQL injection to infer database information and potentially degrade performance or cause denial of service.
Affected context
This vulnerability occurs in Fleet deployments where authenticated users can call endpoints that accept an order_key query parameter used for result sorting.
The issue is tied to dynamic construction of SQL ORDER BY clauses using user-supplied values without strict allow‑listing of sortable columns.
It becomes relevant in environments where users can control sort keys or column names and the backend relies on MySQL with Fleet versions prior to 4.80.1.
Exploit preconditions
- Attack surface: HTTP(S) API endpoints or web UI routes that accept
order_keyand forward it to the database layer. - Required access: Valid authenticated account with permission to access the affected listing or search endpoint.
- Trigger point: Submission of a specially crafted
order_keyvalue that is incorporated into theORDER BYclause viagoqu.I(). - Why exploitation is possible: The
goqu.I()identifier helper is used on untrusted input without strict allow‑listing, allowing attackers to break out of identifier quoting and inject arbitrary SQL expressions into theORDER BYcontext.
Why this happens
The root cause is unsafe dynamic SQL construction using user-controlled input as identifiers in the ORDER BY clause.
Instead of mapping a small, predefined set of logical sort options to hardcoded, parameterized column names, the implementation passed the raw order_key value into goqu.I(), which is intended to represent trusted identifiers.
This effectively bypassed the usual protections of parameterized queries, allowing attacker-provided fragments to be treated as SQL syntax rather than data.
This behavior aligns with CWE-89: SQL Injection, where application code fails to neutralize special elements in SQL commands composed from external input.
Potential impact
- Authenticated attackers may infer contents of database tables using blind SQL injection techniques based on conditional expressions in
ORDER BY. - Sensitive metadata (such as table/column structure or selected field values) could be gradually disclosed.
- Crafted expressions can cause expensive sorting operations or complex computations, leading to performance degradation.
- Repeated abusive requests may contribute to partial denial of service through increased database load or query timeouts.
- Query errors can leak limited structural information about the schema or query behavior.
General mitigation guidance
Effective mitigation patterns focus on eliminating direct use of untrusted values in SQL identifiers and clauses:
- Replace free-form
order_keyhandling with an explicit allow‑list that maps user-facing sort options to fixed, hardcoded column names and directions. - Keep all user input in parameter positions only; avoid passing untrusted values into identifier constructors or direct SQL fragments.
- Introduce a thin query-building layer or helper that only supports predefined sort and filter configurations, rejecting any unknown keys.
- Apply least-privilege principles to the database account used by the application to limit damage if an injection flaw is present.
- Implement centralized validation for all sorting and pagination parameters to ensure they adhere to a known, safe schema.
How teams detect issues like this
Detection typically involves a combination of code-centric and behavior-centric practices:
- Static analysis: Flag any use of SQL builder APIs (such as
goqu.I()or raw SQL fragments) that operate on unvalidated or non-allow‑listed request parameters, especially forORDER BY,GROUP BY, orLIMIT/OFFSETclauses. - Code review: Look for patterns where request query parameters (e.g.,
order_key,sort,column) are passed directly into query builders without mapping through an explicit enumeration of allowed values. - Security testing: Use dynamic application security testing (DAST) or manual penetration testing to probe sort and column parameters with conditional expressions that could influence result ordering or timing.
- Monitoring and logging: Record anomalous query patterns and errors, such as unexpected SQL syntax or unusually complex
ORDER BYexpressions, and set alerts for repeated failures tied to sorting parameters.

