Skip to content

OneUptime ClickHouse vulnerable to SQL Injection via unvalidated column identifiers in sort, select, and groupBy parameters

High severity GitHub Reviewed Published Mar 17, 2026 in OneUptime/oneuptime • Updated Mar 18, 2026

Package

npm oneuptime (npm)

Affected versions

< 10.0.34

Patched versions

10.0.34

Description

The fix for GHSA-p5g2-jm85-8g35 (ClickHouse SQL injection via aggregate query parameters) added column name validation to the _aggregateBy method but did not apply the same validation to three other query construction paths in StatementGenerator. The toSortStatement, toSelectStatement, and toGroupByStatement methods accept user-controlled object keys from API request bodies and interpolate them as ClickHouse Identifier parameters without verifying they correspond to actual model columns.

ClickHouse Identifier parameters are substituted directly into queries without escaping, so an attacker who can reach any analytics list or aggregate endpoint can inject arbitrary SQL through crafted sort, select, or groupBy keys.

Details

Root cause

StatementGenerator.ts has four methods that iterate over user-provided object keys to build SQL:

Method Validates keys?
toWhereStatement (line 292) Yes - calls this.model.getTableColumn(key)
toSortStatement (line 467) No
toSelectStatement (line 483) No
toGroupByStatement (line 451) No

In Statement.ts, when a value passed to the SQL tagged template is a string, it receives the Identifier data type (line 40). Per ClickHouse documentation, Identifier parameters are substituted directly into the query without quoting or escaping. This is correct for trusted column names but unsafe for user input.

Input flow

BaseAnalyticsAPI.ts deserializes sort, select, and groupBy directly from req.body (lines 239-253) and passes them to the service layer without column validation:

sort = JSONFunctions.deserialize(req.body["sort"]) as Sort<AnalyticsDataModel>;
select = JSONFunctions.deserialize(req.body["select"]) as Select<AnalyticsDataModel>;
groupBy = JSONFunctions.deserialize(req.body["groupBy"]) as GroupBy<AnalyticsDataModel>;

Affected endpoints

Any endpoint backed by BaseAnalyticsAPI.getList() or BaseAnalyticsAPI.getAggregate() - this includes analytics queries for logs, metrics, spans, and exceptions.

Impact

An authenticated user can inject arbitrary ClickHouse SQL through crafted column names in sort, select, or groupBy request parameters. This allows reading, modifying, or deleting analytics data (logs, metrics, traces) stored in ClickHouse. PostgreSQL data is not affected (separate query path).

Suggested Fix

Add the same getTableColumn() validation already present in toWhereStatement to the three unvalidated methods:

// toSortStatement, toSelectStatement, toGroupByStatement
for (const key in sort) {
  if (!this.model.getTableColumn(key)) {
    throw new BadDataException(`Unknown column: ${key}`);
  }
  // existing logic
}

This matches the pattern used in the GHSA-p5g2 fix for _aggregateBy and the existing toWhereStatement validation.

References

@simlarsen simlarsen published to OneUptime/oneuptime Mar 17, 2026
Published to the GitHub Advisory Database Mar 18, 2026
Reviewed Mar 18, 2026
Last updated Mar 18, 2026

Severity

High

CVSS overall score

This score calculates overall vulnerability severity from 0 to 10 and is based on the Common Vulnerability Scoring System (CVSS).
/ 10

CVSS v3 base metrics

Attack vector
Network
Attack complexity
Low
Privileges required
Low
User interaction
None
Scope
Unchanged
Confidentiality
High
Integrity
High
Availability
None

CVSS v3 base metrics

Attack vector: More severe the more the remote (logically and physically) an attacker can be in order to exploit the vulnerability.
Attack complexity: More severe for the least complex attacks.
Privileges required: More severe if no privileges are required.
User interaction: More severe when no user interaction is required.
Scope: More severe when a scope change occurs, e.g. one vulnerable component impacts resources in components beyond its security scope.
Confidentiality: More severe when loss of data confidentiality is highest, measuring the level of data access available to an unauthorized user.
Integrity: More severe when loss of data integrity is the highest, measuring the consequence of data modification possible by an unauthorized user.
Availability: More severe when the loss of impacted component availability is highest.
CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:N

EPSS score

Weaknesses

Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')

The product constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component. Without sufficient removal or quoting of SQL syntax in user-controllable inputs, the generated SQL query can cause those inputs to be interpreted as SQL instead of ordinary user data. Learn more on MITRE.

CVE ID

CVE-2026-33142

GHSA ID

GHSA-gcg3-c5p2-cqgg

Source code

Credits

Loading Checking history
See something to contribute? Suggest improvements for this vulnerability.