/

CVE-2026-61461

Severity:

HIGH RISK

(8.8)

SQL Injection (CWE-89) in Dify MyScale Vector Store

CVE-2026-61461

Analyzed

Vulnerability type

Category:

SQL Injection

CWE:

CWE-89

Impact:

Arbitrary SQL Execution and Data Compromise

Severity:

HIGH RISK

(8.8)

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

Dify's MyScale vector store backend contains a SQL injection flaw in the search_by_full_text method that allows arbitrary SQL execution via unsanitized search parameters.

When user-supplied search text is concatenated into ClickHouse queries without escaping or parameterization, attackers can inject SQL to read, modify, or delete data in the underlying database.

Affected context

This vulnerability occurs in Dify deployments that use the MyScale vector store backend and rely on the search_by_full_text method for full-text search.

It is relevant when user-controlled search parameters are passed directly into ClickHouse queries without parameter binding, escaping, or query construction safeguards.

Environments where the application has broad database privileges are more exposed, but the risk can exist in any setup that treats search text as trusted input.

Exploit preconditions

  • Attack surface: Application interfaces that accept search text (e.g., API endpoints, UI search boxes) and route it into the MyScale search_by_full_text call.
  • Required access: Ability to submit search parameters to the affected method; typically unauthenticated or low-privilege user input is sufficient.
  • Trigger point: Execution of dynamically built ClickHouse queries where search text is concatenated directly into the SQL string.
  • Why exploitation is possible: The query builder does not use parameterized statements or proper escaping, allowing input to alter the query structure instead of being treated purely as data.

Why this happens

The underlying bug is classic SQL injection as described by CWE-89: Improper Neutralization of Special Elements used in an SQL Command.

The MyScale vector store backend constructs ClickHouse SQL queries by interpolating raw search parameters into the query string, assuming they are safe.

Because the application does not enforce separation between query logic and user data (e.g., via prepared statements or robust query builders), an attacker can include SQL control characters and syntax that the database interprets as part of the command.

This insecure pattern—forming SQL via string concatenation with untrusted input—allows attackers to override filters, join additional tables, or append destructive operations.

Potential impact

  • Attackers may read sensitive data from ClickHouse tables beyond what the application normally exposes.
  • Malicious queries could modify or delete stored vectors and metadata, degrading search quality or destroying records.
  • Injected SQL can bypass application-level access controls and row-level filters where enforced only in the query logic.
  • An attacker could tamper with analytics or logging data, leading to misleading insights or masking other attacks.
  • If the database user has administrative privileges, configuration changes or broader data exfiltration can occur.

General mitigation guidance

Effective mitigation focuses on eliminating direct string concatenation of SQL with untrusted input and narrowing database privileges.

Recommended defensive patterns include:

  • Adopting parameterized queries or prepared statements for all search operations, ensuring user input is always treated as data.
  • Using vetted query builder libraries that abstract SQL construction and enforce safe interpolation.
  • Applying strict input validation and normalization for search parameters, limiting allowed characters and patterns where feasible.
  • Segmenting database privileges so the application role can only perform the minimal set of read/write operations required.
  • Implementing least-privilege access to ClickHouse tables and views, and avoiding exposing raw base tables when derived views suffice.
  • Designing search APIs to avoid passing raw user text directly into dynamic SQL clauses (such as ORDER BY, LIMIT, or arbitrary WHERE fragments).

How teams detect issues like this

Detection typically combines static analysis, code review, and runtime monitoring:

  • Static analysis rules can flag SQL construction that uses string concatenation or interpolation with user-controlled variables, especially in data access layers.
  • Code review processes should look for direct SELECT ... strings that accept search text, ensuring prepared statements or query builders are used.
  • Security linters and CI policies can enforce patterns such as "no raw SQL with concatenated parameters" in specific modules (e.g., vector store backends).
  • Database-level monitoring can detect anomalous queries, such as unexpected table access, UNIONs, or destructive operations originating from search-related endpoints.
  • Automated application security testing (DAST) and fuzzing tools can be configured to probe search interfaces for injection behavior and unexpected error responses.

Sources

SourceLink
github.comgithub.com/langgenius/dify/commit/d9884efaeea8322706e24c560d2c17e5bf3fab5f
github.comgithub.com/langgenius/dify/issues/38281
github.comgithub.com/langgenius/dify/pull/38295
github.comgithub.com/langgenius/dify/releases/tag/1.16.0-rc1
vulncheck.comvulncheck.com/advisories/dify-rc1-sql-injection-via-myscale-vector-store-search-by-full-text

Frequently asked

questions

It can be broadly exploitable wherever the affected search_by_full_text method is reachable via user-supplied search parameters. If search endpoints are public or low-friction to access, attackers can typically exploit the flaw remotely without special privileges.

An attacker usually only needs the ability to submit search text through the application interface that maps to the vulnerable method. No direct database access is required; exploitation happens through the application's own database connection.

The safest pattern is to refactor all dynamic SQL in the MyScale backend to use parameterized queries or prepared statements, and to ensure that user input is never concatenated into SQL strings. Where possible, restrict queries to a fixed structure and only bind sanitized values in placeholders.

Standardize the use of secure data access layers that rely on parameterization, enforce code-level guidelines banning raw SQL concatenation, and integrate static analysis or linters into CI to detect unsafe query patterns. Additionally, apply least-privilege database roles so that, even if an injection slips through, the blast radius is limited.

Find out what's already
exploitable in your codebase.