/

CVE-2026-33142

Severity:

HIGH RISK

(8.1)

SQL Injection in OneUptime Analytics StatementGenerator

CVE-2026-33142

Analyzed

Vulnerability type

Category:

SQL Injection

CWE:

CWE-89

Impact:

Arbitrary SQL Query Manipulation in Analytics Back-End

Severity:

HIGH RISK

(8.1)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

OneUptime's analytics endpoints contained a SQL injection flaw where user-controlled object keys were interpolated as ClickHouse Identifier parameters without validation.

An attacker who can access list or aggregate analytics APIs could inject arbitrary SQL through crafted sort, select, or groupBy keys, potentially leading to data exposure or modification within the analytics database.

Affected context

This vulnerability appears in OneUptime deployments that:

  • Use the analytics APIs backed by ClickHouse, and
  • Rely on the StatementGenerator utility to construct SELECT, GROUP BY, and ORDER BY clauses, and
  • Accept request body parameters for sorting, selecting, or grouping analytics data.

The issue is present when application logic trusts client-provided object keys (e.g., field names) and passes them directly into query construction without checking that they are valid model columns.

Exploit preconditions

  • Attack surface: Any reachable analytics list or aggregate endpoint that allows clients to specify sort, select, or groupBy options.
  • Required access: Network access and any authentication level needed to reach these endpoints (often a regular user with analytics access).
  • Trigger point: Submission of crafted JSON bodies or query parameters whose keys are consumed by toSortStatement, toSelectStatement, or toGroupByStatement.
  • Why exploitation is possible: The StatementGenerator treats user-controlled keys as ClickHouse Identifier parameters and interpolates them without verifying they map to permitted model columns. Since ClickHouse Identifiers are substituted directly into the SQL without escaping, this enables injection into query structure.

Why this happens

The underlying flaw is a classic SQL injection pattern (CWE-89) involving untrusted data used to dynamically construct query fragments.

Instead of using a closed list of allowed column names or mapping client fields to internal identifiers, the code paths toSortStatement, toSelectStatement, and toGroupByStatement accept arbitrary object keys from API requests and inject them into ClickHouse query strings as identifier tokens.

Because identifier parameters in this context are not escaped and are treated as part of the SQL syntax, an attacker can craft keys that alter the structure of the query (e.g., adding additional expressions, functions, or clauses) rather than simply referencing benign columns.

Potential impact

  • Exposure of additional analytics data that would not normally be returned to the requesting user.
  • Modification or corruption of analytics results, leading to incorrect reporting and decision-making.
  • Circumvention of application-level query restrictions by injecting additional functions or clauses.
  • Potential escalation to broader database compromise, depending on ClickHouse configuration, permissions, and available SQL features.

General mitigation guidance

Effective mitigation focuses on eliminating direct use of untrusted identifiers and constraining query construction:

  • Introduce a strict allowlist of valid model columns, and map any client-provided field names to these known identifiers before building queries.
  • Use structured query builders or ORM-like abstractions where identifiers are derived from schema metadata, not from raw client input.
  • Normalize and validate sort, select, and groupBy specifications against server-side definitions (e.g., enumerations or configuration objects) instead of trusting arbitrary keys.
  • Apply least-privilege to the analytics database user so even if a query is manipulated, the account cannot perform destructive operations or access unrelated schemas.
  • Design APIs so that clients choose from predefined analytics dimensions and metrics, rather than constructing free-form query fragments.

How teams detect issues like this

Detection typically involves both code-centric and runtime approaches:

  • Static analysis: Configure rules to flag string concatenation or identifier interpolation in query builders, especially where input originates from request bodies or query parameters.
  • Code review: Pay particular attention to utility classes like StatementGenerator that centralize query construction, checking that all paths enforce identifier validation and use allowlists.
  • Schema-aware checks: Implement unit or integration tests that verify only known column names can be used in sort/select/groupBy options; reject any unexpected identifier.
  • Runtime monitoring: Analyze database logs for unusual queries containing unexpected column names or syntactic anomalies, and correlate them with API calls that include custom sorting or grouping options.

Sources

SourceLink
github.comgithub.com/OneUptime/oneuptime/security/advisories/GHSA-gcg3-c5p2-cqgg

Frequently asked

questions

Yes. Any user or service that can send requests to the affected analytics endpoints and control sort, select, or groupBy keys can potentially exploit the flaw, subject to whatever authentication the API requires.

The attacker needs sufficient privileges to reach analytics list or aggregate endpoints—typically a standard authenticated account with analytics access. They do not need database-level access; the injection occurs through the application's query builder.

Replace direct interpolation of client-controlled identifiers with an allowlisted mapping: maintain a server-side dictionary of valid column names, map external field names to these internal identifiers, and reject any unknown or disallowed keys. Centralize this logic so all query construction paths (select, sort, groupBy, aggregate) use the same validation.

Design APIs so clients interact with high-level analytics concepts (dimensions, metrics, pre-defined views) rather than constructing query fragments. Combine this with secure coding practices: use parameterized queries for values, apply strict allowlists for identifiers, enforce static analysis rules for dynamic SQL, and subject shared query-builder utilities to focused security review and testing.

Find out what's already
exploitable in your codebase.