Skip to main content
Vulnerability Database/CVE-2026-55239

CVE-2026-55239: Tianji Analytics Platform SQL Injection Vulnerability

CVE-2026-55239 is a SQL injection flaw in Tianji open source analytics platform that allows authenticated users to execute arbitrary SQL queries. This post explains its impact, affected versions, and mitigation steps.

Published:

Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

Sources: National Vulnerability Database, CISA KEV, Exploit-DB

CVE-2026-55239 Overview

Tianji is an open-source analytics, uptime monitoring, and server status platform. A SQL injection vulnerability [CWE-89] affects all versions prior to 1.31.29. The getDateQuery() function in src/server/utils/prisma.ts constructs raw SQL through Prisma.sql() by interpolating the timezone request value without parameter binding. Any authenticated workspace member, including read-only viewers, can reach the vulnerable queries through the workspaceProcedure endpoint.

Critical Impact

An authenticated attacker can execute arbitrary SQL against the shared PostgreSQL database, disclosing or modifying credentials, API keys, and tenant data, or rendering the service unavailable.

Affected Products

  • Tianji versions prior to 1.31.29
  • Deployments using the shared PostgreSQL backend
  • Any multi-tenant Tianji workspace with authenticated viewers

Discovery Timeline

  • 2026-10-15 - CVE-2026-55239 published to the National Vulnerability Database (NVD)
  • 2026-10-21 - Last updated in NVD database

Technical Details for CVE-2026-55239

Vulnerability Analysis

The flaw resides in the getDateQuery() helper located at src/server/utils/prisma.ts. The function builds raw SQL fragments using Prisma.sql() and interpolates a caller-supplied timezone value directly into the query text. Because the interpolation bypasses parameter binding, PostgreSQL treats the attacker-controlled string as SQL syntax rather than data.

The timezone value is accepted from request bodies and from the timezone HTTP header. It propagates through analytics queries exposed by workspaceProcedure, which authorizes any authenticated workspace member. Read-only viewers, who are expected to have no write capability, can therefore trigger database writes and arbitrary query execution against the shared PostgreSQL instance that stores all tenants.

Root Cause

The root cause is unsafe string interpolation into a raw SQL template. Prisma's sql tagged template performs parameter binding only for ${} placeholders bound as values. When caller input is passed through raw or concatenated into the template, it is treated as trusted SQL. The timezone parameter followed this unsafe path and was never validated against an allowlist of IANA timezone names.

Attack Vector

Exploitation requires only workspace-level authentication. An attacker sends an analytics request to the vulnerable workspaceProcedure route and places malicious SQL in either the request body's timezone field or the timezone HTTP header. The injected payload executes with the privileges of the Tianji database role, which has broad access to all tenant tables.

typescript
// Security patch excerpt — src/server/model/insights/survey.ts
   processGroupedTimeSeriesData,
 } from './utils.js';
 import { prisma } from '../_client.js';
+import { quoteSqlIdentifier } from '../../utils/sql.js';
 
 const { sql, raw } = Prisma;

Source: GitHub Commit 132ff67

The fix introduces a quoteSqlIdentifier helper that safely quotes identifiers and values before they are embedded in raw SQL templates across the insights and website analytics modules.

Detection Methods for CVE-2026-55239

Indicators of Compromise

  • Unusual values in the timezone HTTP header containing SQL metacharacters such as single quotes, semicolons, or UNION keywords
  • PostgreSQL logs showing analytics queries with syntactically unexpected timezone fragments or errors referencing injected identifiers
  • Unexpected read or write access to tables outside the requesting workspace's tenant scope
  • Analytics API requests from read-only viewer accounts that correlate with database errors

Detection Strategies

  • Inspect reverse proxy and application logs for timezone header or body values that do not match the IANA timezone format (for example, Area/City)
  • Enable PostgreSQL log_statement = 'all' temporarily and search for analytics queries containing injected SQL tokens
  • Correlate workspace member role (viewer) with modification events on sensitive tables such as credentials, API keys, and tenant configuration

Monitoring Recommendations

  • Alert on authenticated requests to Tianji analytics endpoints that produce PostgreSQL syntax errors
  • Track outbound connections from the Tianji host for signs of data exfiltration following suspicious analytics calls
  • Monitor Tianji container image versions in deployment pipelines and flag any running version below 1.31.29

How to Mitigate CVE-2026-55239

Immediate Actions Required

  • Upgrade Tianji to version 1.31.29 or later, which hardens the raw SQL templates in the insights and website modules
  • Rotate any credentials, API keys, and database secrets stored in the Tianji PostgreSQL database, as prior access cannot be ruled out
  • Audit workspace membership and remove inactive or untrusted viewer accounts
  • Review PostgreSQL logs covering the period before patching for signs of injected analytics queries

Patch Information

The vulnerability is fixed in Tianji 1.31.29. The patch introduces quoteSqlIdentifier for safe identifier handling and refactors raw SQL construction in src/server/model/insights/survey.ts and src/server/model/insights/website.ts. See the GitHub Security Advisory GHSA-v9jm-vvrj-53c4 and the v1.31.29 release notes.

Workarounds

  • Restrict workspace membership to trusted users until the upgrade can be completed
  • Place a reverse proxy rule that rejects requests whose timezone header or body value does not match a strict IANA timezone allowlist
  • Enforce least privilege on the Tianji PostgreSQL role, limiting write and schema access where feasible
bash
# Example NGINX rule to drop requests with non-IANA timezone headers
map $http_timezone $tz_invalid {
    default                                          1;
    "~^[A-Za-z]+(/[A-Za-z_\-]+){1,2}$"                0;
}

server {
    location /trpc/ {
        if ($tz_invalid) { return 400; }
        proxy_pass http://tianji_upstream;
    }
}

Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

Sources: National Vulnerability Database, CISA KEV, Exploit-DB

Experience the Most Advanced Cybersecurity Platform

See how the world’s most intelligent, autonomous cybersecurity platform can protect your organization today and into the future.