/

CVE-2026-51992

Severity:

CRITICAL RISK

(9.1)

SQL Injection (CWE-89) in ClickHouse dictionary creation

CVE-2026-51992

Deferred

Vulnerability type

Category:

SQL Injection

CWE:

CWE-89

Impact:

Remote Code Execution via SQL Injection

Severity:

CRITICAL RISK

(9.1)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

A SQL Injection vulnerability in ClickHouse Server's dictionary creation functionality allows crafted input to be interpreted as executable SQL rather than data.

When exposed to remote attackers through query interfaces, this weakness can enable arbitrary code or command execution with the server's privileges.

A SQL Injection vulnerability in ClickHouse Server's dictionary creation functionality allows crafted input to be interpreted as executable SQL rather than data.

When exposed to remote attackers through query interfaces, this weakness can enable arbitrary code or command execution with the server's privileges.

Affected context

This vulnerability occurs in environments where ClickHouse Server exposes dictionary creation capabilities (e.g., CREATE DICTIONARY or related functions) to client queries.

It is most relevant when user-controllable parameters, configuration values, or external data sources are incorporated into dictionary definitions without strict validation or parameterization.

Multi-tenant deployments, shared analytics clusters, or services providing ad-hoc query features are especially at risk when untrusted inputs can influence dictionary creation.

This vulnerability occurs in environments where ClickHouse Server exposes dictionary creation capabilities (e.g., CREATE DICTIONARY or related functions) to client queries.

It is most relevant when user-controllable parameters, configuration values, or external data sources are incorporated into dictionary definitions without strict validation or parameterization.

Multi-tenant deployments, shared analytics clusters, or services providing ad-hoc query features are especially at risk when untrusted inputs can influence dictionary creation.

Exploit preconditions

  • Attack surface: Remote query interfaces to ClickHouse Server (SQL endpoints, APIs, or services that forward queries).
  • Required access: Ability to submit or influence SQL statements that invoke dictionary creation, or supply values interpolated into those statements.
  • Trigger point: Execution of dictionary-related SQL where untrusted input is concatenated or embedded into query text without proper escaping or parameterization.
  • Why exploitation is possible: The server treats attacker-controlled input as part of executable SQL, allowing injection of additional clauses, function calls, or commands that abuse dictionary mechanisms for arbitrary code execution.
  • Attack surface: Remote query interfaces to ClickHouse Server (SQL endpoints, APIs, or services that forward queries).
  • Required access: Ability to submit or influence SQL statements that invoke dictionary creation, or supply values interpolated into those statements.
  • Trigger point: Execution of dictionary-related SQL where untrusted input is concatenated or embedded into query text without proper escaping or parameterization.
  • Why exploitation is possible: The server treats attacker-controlled input as part of executable SQL, allowing injection of additional clauses, function calls, or commands that abuse dictionary mechanisms for arbitrary code execution.

Why this happens

The underlying bug aligns with CWE-89: Improper Neutralization of Special Elements used in an SQL Command (SQL Injection).

Instead of strictly separating data from executable SQL, the dictionary creation logic composes queries by embedding raw, user-controllable values directly into SQL strings.

This pattern fails to neutralize metacharacters, operators, and control tokens, allowing attackers to break out of intended expressions and inject their own SQL or execution paths.

Abstractly, the insecure pattern is: dynamic SQL construction from untrusted inputs without parameter binding, escaping, or structural validation, combined with powerful server-side capabilities exposed via dictionary creation.

The underlying bug aligns with CWE-89: Improper Neutralization of Special Elements used in an SQL Command (SQL Injection).

Instead of strictly separating data from executable SQL, the dictionary creation logic composes queries by embedding raw, user-controllable values directly into SQL strings.

This pattern fails to neutralize metacharacters, operators, and control tokens, allowing attackers to break out of intended expressions and inject their own SQL or execution paths.

Abstractly, the insecure pattern is: dynamic SQL construction from untrusted inputs without parameter binding, escaping, or structural validation, combined with powerful server-side capabilities exposed via dictionary creation.

Potential impact

  • Remote attackers may execute arbitrary SQL statements within the ClickHouse Server context.
  • Attackers could escalate to arbitrary code execution via server-side functions or dictionary backends.
  • Sensitive data stored in ClickHouse tables may be read, modified, or deleted.
  • Dictionary configurations and external data sources can be tampered with, impacting analytics integrity.
  • Compromise of the ClickHouse instance can facilitate lateral movement to other systems in the environment.
  • Remote attackers may execute arbitrary SQL statements within the ClickHouse Server context.
  • Attackers could escalate to arbitrary code execution via server-side functions or dictionary backends.
  • Sensitive data stored in ClickHouse tables may be read, modified, or deleted.
  • Dictionary configurations and external data sources can be tampered with, impacting analytics integrity.
  • Compromise of the ClickHouse instance can facilitate lateral movement to other systems in the environment.

General mitigation guidance

Mitigation focuses on eliminating unsafe dynamic SQL patterns and constraining powerful server capabilities exposed to user input.

Common defensive approaches include:

  • Using parameterized queries or structured APIs for dictionary creation instead of manual string concatenation.
  • Applying strict validation and whitelisting of dictionary names, data source parameters, and configuration options influencing SQL.
  • Segregating privileges so that dictionary creation and management are restricted to trusted service accounts, not general users or tenants.
  • Reducing the expressiveness of inputs by limiting allowed characters and disallowing SQL metacharacters in fields incorporated into dictionary definitions.
  • Implementing least-privilege execution for ClickHouse Server and disabling unneeded functions or external integrations to reduce impact if injection occurs.

Mitigation focuses on eliminating unsafe dynamic SQL patterns and constraining powerful server capabilities exposed to user input.

Common defensive approaches include:

  • Using parameterized queries or structured APIs for dictionary creation instead of manual string concatenation.
  • Applying strict validation and whitelisting of dictionary names, data source parameters, and configuration options influencing SQL.
  • Segregating privileges so that dictionary creation and management are restricted to trusted service accounts, not general users or tenants.
  • Reducing the expressiveness of inputs by limiting allowed characters and disallowing SQL metacharacters in fields incorporated into dictionary definitions.
  • Implementing least-privilege execution for ClickHouse Server and disabling unneeded functions or external integrations to reduce impact if injection occurs.

How teams detect issues like this

Effective detection typically combines code-level and runtime strategies:

  • Static analysis rules to flag dynamic SQL construction involving untrusted variables in dictionary-related modules or query-building libraries.
  • Code review checklists that require parameterized query APIs and prohibit manual concatenation for any SQL involving user data.
  • Logging and monitoring of dictionary creation statements, with alerts on anomalous patterns such as unexpected function calls, subqueries, or stacked statements.
  • Security policy enforcement in CI/CD pipelines that scans configuration and query templates for injection-prone constructs.
  • Periodic penetration testing or fuzzing of query endpoints to identify unexpected behaviors when special characters and SQL keywords are supplied in parameters.

Effective detection typically combines code-level and runtime strategies:

  • Static analysis rules to flag dynamic SQL construction involving untrusted variables in dictionary-related modules or query-building libraries.
  • Code review checklists that require parameterized query APIs and prohibit manual concatenation for any SQL involving user data.
  • Logging and monitoring of dictionary creation statements, with alerts on anomalous patterns such as unexpected function calls, subqueries, or stacked statements.
  • Security policy enforcement in CI/CD pipelines that scans configuration and query templates for injection-prone constructs.
  • Periodic penetration testing or fuzzing of query endpoints to identify unexpected behaviors when special characters and SQL keywords are supplied in parameters.

Sources

SourceLink
clickhouse.comclickhouse.com/docs/sql-reference/dictionaries#postgresql
github.comgithub.com/TheLiimbo/CVE-2026-51992

Frequently asked

questions

Yes, if ClickHouse Server is reachable over the network and exposes interfaces that allow dictionary creation or pass user-controlled values into such operations, a remote attacker can attempt SQL injection through those entry points.

The attacker must be able to issue SQL queries or influence parameters that are integrated into dictionary creation statements. This may be direct database access, an application-layer API, or any service that forwards user input into ClickHouse queries without adequate sanitization.

The most robust fix is to remove dynamic string-based SQL construction for dictionary creation and rely on parameterized, structured query interfaces. Combine this with strict input validation and minimize the set of users or services allowed to create or modify dictionaries.

Adopt a development standard that forbids concatenating untrusted input into SQL, enforce the use of parameterized queries and query builders, integrate static analysis and security reviews into the development lifecycle, and keep powerful database capabilities (like dictionary management and external functions) locked behind strong access controls by default.

Yes, if ClickHouse Server is reachable over the network and exposes interfaces that allow dictionary creation or pass user-controlled values into such operations, a remote attacker can attempt SQL injection through those entry points.

The attacker must be able to issue SQL queries or influence parameters that are integrated into dictionary creation statements. This may be direct database access, an application-layer API, or any service that forwards user input into ClickHouse queries without adequate sanitization.

The most robust fix is to remove dynamic string-based SQL construction for dictionary creation and rely on parameterized, structured query interfaces. Combine this with strict input validation and minimize the set of users or services allowed to create or modify dictionaries.

Adopt a development standard that forbids concatenating untrusted input into SQL, enforce the use of parameterized queries and query builders, integrate static analysis and security reviews into the development lifecycle, and keep powerful database capabilities (like dictionary management and external functions) locked behind strong access controls by default.

Find out what's already
exploitable in your codebase.