Summary
SigNoz through version 0.130.1 contains a SQL injection flaw in its alert-history endpoints where a rule ID path parameter is interpolated into ClickHouse queries without proper sanitization.
An authenticated attacker can inject URL-encoded quotes into the rule ID, execute arbitrary ClickHouse queries, and potentially read all traces, logs, and metrics or abuse ClickHouse functions for server-side request forgery.
Affected context
This vulnerability occurs in SigNoz deployments where alert-history endpoints are exposed and rely on a rule ID supplied via an HTTP path parameter.
The risk is present when:
- ClickHouse is used as the backend for observability data,
- The application constructs SQL queries with string interpolation instead of parameter binding,
- The rule ID is treated as trusted input and not validated, escaped, or constrained.
Exploit preconditions
- Attack surface: HTTP alert-history API endpoints accepting a rule ID path parameter.
- Required access: Valid authenticated access to SigNoz with permissions to query alert history.
- Trigger point: Submission of a crafted rule ID that injects URL-encoded quotes and SQL fragments into the interpolated ClickHouse query.
- Why exploitation is possible: The rule ID is directly concatenated into SQL strings without parameterization or robust input validation, allowing the attacker-controlled value to alter query structure.
Why this happens
The underlying issue maps to CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection').
Application code dynamically builds ClickHouse queries by interpolating a rule ID path parameter into the query string.
Because the input is not sanitized and no prepared statements or bound parameters are used, special characters (such as quotes) can break out of the intended literal context and introduce arbitrary SQL clauses, including function calls like url().
This insecure pattern stems from treating user-provided identifiers as safe to embed directly into SQL, rather than enforcing strict typing, whitelisting, or parameterization.
Potential impact
- Attackers may read all stored traces, logs, and metrics from ClickHouse.
- Attackers could query sensitive internal observability metadata beyond their normal permissions.
- Attackers may perform server-side request forgery (SSRF) using ClickHouse functions like
url()to reach internal services. - Attackers could manipulate monitoring data, impacting incident response and reliability analysis.
- Attackers can potentially pivot to other systems if internal endpoints exposed via SSRF are vulnerable.
General mitigation guidance
Effective mitigation focuses on eliminating direct string interpolation in SQL construction and reducing trust in request parameters.
Recommended design patterns include:
- Use parameterized queries or prepared statements for all interactions with ClickHouse, ensuring values are bound as data rather than concatenated into SQL syntax.
- Apply strict validation and whitelisting to identifiers like rule IDs (e.g., enforce allowed character sets, length limits, and structural constraints).
- Introduce an intermediate abstraction for query building that disallows raw string injection and encodes values safely.
- Reduce privileges for the database user used by SigNoz so it only has the minimum read/write access necessary for observability operations.
- Limit or disable high-risk database functions (such as arbitrary HTTP/URL fetch mechanisms) where operationally feasible.
How teams detect issues like this
Organizations can detect this class of vulnerability and its exploitation using several approaches:
- Static analysis rules that flag dynamic SQL construction using string concatenation or format operations involving HTTP parameters or path variables.
- Code review checklists that require verification of parameterized queries and prohibit direct embedding of request data into SQL.
- Runtime monitoring of ClickHouse query logs for anomalous patterns, such as unexpected
url()function usage or queries referencing atypical system tables. - Application-layer logging that captures suspicious rule ID values containing encoded quotes or SQL meta-characters, coupled with alerting.
- Security policies integrated into CI/CD pipelines that enforce use of query builder APIs or ORM layers designed to prevent SQL injection.

