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

CVE-2026-55240: Tianji Template Injection RCE Vulnerability

CVE-2026-55240 is a template injection RCE flaw in Tianji that lets unauthenticated users execute server-side code through survey submissions. This post covers technical details, affected versions, impact, and mitigation.

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-55240 Overview

CVE-2026-55240 is a server-side template injection vulnerability in Tianji, an open source analytics, uptime monitoring, and server status platform. Versions prior to 1.31.29 pass survey and monitor notification templates to the lodash template() function with the default evaluate pattern enabled. A workspace administrator can store an <% code %> block in a survey template. When an unauthenticated user submits a response to the public survey.submit endpoint, the compiled template runs attacker-controlled JavaScript inside the Tianji Node.js process. The flaw is tracked under CWE-1336 and fixed in version 1.31.29.

Critical Impact

Successful exploitation yields server-side JavaScript execution in the Tianji Node.js process, enabling command execution, secret disclosure, data tampering, and service disruption.

Affected Products

  • Tianji versions prior to 1.31.29
  • Survey feed templates processed by formatString() in src/server/utils/template.ts
  • Monitor notification templates processed by the same template helper

Discovery Timeline

  • 2026-10-15 - CVE-2026-55240 published to NVD
  • 2026-10-16 - Last updated in NVD database

Technical Details for CVE-2026-55240

Vulnerability Analysis

Tianji's formatString() helper in src/server/utils/template.ts delegates rendering to lodash's template() function. The default lodash template configuration enables the evaluate delimiter (<% ... %>), which treats the enclosed content as executable JavaScript during template compilation. Because Tianji passes administrator-authored survey feed templates and monitor notification templates through this helper without stripping or escaping the evaluate delimiter, a malicious workspace administrator can embed arbitrary JavaScript that executes server-side when the template is rendered.

The trigger path is the public survey.submit endpoint, which accepts unauthenticated submissions and renders the configured survey template to produce feed output. An unauthenticated request is therefore sufficient to invoke the stored payload. The resulting execution occurs inside the Tianji Node.js process with the privileges of the service account, exposing credentials, database contents, and any resources reachable from the host.

Root Cause

The root cause is a classic template engine misuse pattern classified under CWE-1336: Improper Neutralization of Special Elements Used in a Template Engine. Tianji relied on administrator trust boundaries while using a template engine whose default behavior is to execute code, instead of restricting rendering to interpolation-only semantics or using a sandboxed engine.

Attack Vector

An authenticated workspace administrator stores a template containing an <% ... %> block in either a survey feed template or a monitor notification template. An unauthenticated attacker then sends a request to the survey.submit endpoint tied to that survey. Tianji compiles and executes the template server-side, running the attacker-controlled JavaScript. No user interaction beyond submission is required, and the attack is reachable over the network.

typescript
// Security patch references from the fix commit
// Source: https://github.com/msgbyte/tianji/commit/132ff67907df897d222829ea8ad1a018ff74df48

// 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;

// src/server/model/insights/website.ts
 import { clickhouse } from '../../clickhouse/index.js';
 import { logger } from '../../utils/logger.js';
 import { clickhouseHealthManager } from '../../clickhouse/health.js';
+import { quoteSqlIdentifier } from '../../utils/sql.js';

 const { sql, raw } = Prisma;

The commit 132ff679 hardens template rendering and additionally quotes SQL identifiers in the insights layer. Refer to GHSA-5grg-j3cr-3hpm for the complete advisory.

Stop Remote Code Execution Before It Runs

Singularity™ Endpoint detects and blocks exploit attempts at machine speed, including zero-days and novel attack techniques.

Stop Exploit Attempts

Detection Methods for CVE-2026-55240

Indicators of Compromise

  • Survey or monitor notification templates stored in the Tianji database that contain the lodash evaluate delimiter <% ... %>.
  • Unexpected child processes spawned by the Tianji Node.js process, including shells, curl, wget, or interpreters.
  • Outbound network connections from the Tianji host to unfamiliar destinations shortly after survey.submit requests.
  • Modifications to Tianji configuration files, environment variables, or secrets without a corresponding administrative action.

Detection Strategies

  • Query the Tianji database for survey feed templates and notification templates whose contents match the regex <%[\s\S]*?%>.
  • Review web server and application logs for survey.submit requests that correlate with anomalous process activity on the host.
  • Compare the running Tianji version against 1.31.29 and flag any instance below that threshold.

Monitoring Recommendations

  • Enable process-execution telemetry on the Tianji host and alert on any non-Node child process launched by the Node.js runtime.
  • Monitor file integrity for the Tianji installation directory and secret stores accessible to the service account.
  • Alert on egress connections from the Tianji host to destinations outside the expected analytics and uptime targets.

How to Mitigate CVE-2026-55240

Immediate Actions Required

  • Upgrade Tianji to version 1.31.29 or later without delay.
  • Audit all stored survey feed templates and monitor notification templates for <% ... %> blocks and remove any that were not authored by a trusted administrator.
  • Rotate credentials, API tokens, and database secrets reachable from the Tianji process if any suspicious template was present.
  • Review workspace administrator accounts and revoke access that is no longer required.

Patch Information

The fix is available in Tianji v1.31.29. The remediation commit 132ff679 hardens template handling and tightens SQL identifier quoting in the insights pipeline. See the GitHub Security Advisory GHSA-5grg-j3cr-3hpm for full details.

Workarounds

  • Restrict workspace administrator privileges to a minimal set of fully trusted operators until the upgrade is complete.
  • Place the Tianji instance behind network controls that limit who can reach the public survey.submit endpoint.
  • Disable or remove surveys and monitor notification templates until the patched version is deployed.
bash
# Upgrade Tianji to the patched release
docker pull msgbyte/tianji:1.31.29
docker stop tianji && docker rm tianji
docker run -d --name tianji \
  -p 12345:12345 \
  --env-file ./tianji.env \
  msgbyte/tianji:1.31.29

# Identify templates containing lodash evaluate blocks
psql -U tianji -d tianji -c \
  "SELECT id, name FROM \"SurveyTemplate\" WHERE content ~ '<%[\s\S]*?%>';"

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.