Summary
CocoIndex's Doris target connector previously constructed ALTER TABLE statements using unvalidated table names, allowing SQL injection when those names originated from untrusted upstream input.
In deployments where upstream systems can influence the target table name, an attacker could craft values that alter or drop arbitrary tables, manipulate schema, or otherwise compromise the underlying Doris database.
Affected context
This vulnerability arises in CocoIndex deployments that use the Doris target connector and dynamically derive the target table name from upstream sources, such as configuration, user-controlled metadata, or external services.
It is most relevant when schema changes are triggered automatically (e.g., during migrations or dynamic schema alignment) and ALTER TABLE SQL statements are built directly from these table names without validation or proper identifier handling.
Exploit preconditions
- Attack surface: The Doris target connector's schema change path, specifically ALTER TABLE operations.
- Required access: Ability to influence or control the configured table name field used by CocoIndex (e.g., through upstream configuration, API input, or pipeline metadata).
- Trigger point: Execution of a schema change that causes CocoIndex to generate and run ALTER TABLE statements using the attacker-controlled table name.
- Why exploitation is possible: The connector interpolates the table name directly into SQL without treating it as a bounded identifier, performing input validation, or using safe identifier-quoting APIs, enabling injection of additional SQL fragments.
Why this happens
The underlying bug is a classic CWE-89: SQL Injection issue where untrusted data is concatenated into SQL statements.
Instead of treating the table name as an opaque identifier and validating or constraining it, the Doris connector directly interpolates the configured table name into ALTER TABLE statements at runtime.
This pattern bypasses the separation between data and code in the SQL layer, allowing attacker-controlled values to modify the intended SQL syntax and execute arbitrary commands within the same database session.
Potential impact
- Attackers could alter or drop arbitrary Doris tables accessible to the connector.
- Data in target tables can be corrupted, truncated, or restructured unexpectedly.
- Unauthorized schema changes could destabilize downstream analytics or AI pipelines.
- In some configurations, attackers may escalate impact by chaining injected statements to manipulate permissions or exfiltrate sensitive data.
General mitigation guidance
Mitigation efforts generally focus on enforcing strict boundaries between untrusted input and SQL construction, especially for identifiers such as table names:
- Constrain table names to a known safe set wherever possible (e.g., configuration-based mapping or whitelisting).
- Apply strict validation to identifier-like inputs: allow only expected patterns (e.g., alphanumeric plus underscores) and reject anything else.
- Use safe identifier-quoting mechanisms or ORM/query builder features that treat identifiers as opaque values rather than raw string fragments.
- Separate configuration trust levels so that table naming is not directly influenced by user-supplied or low-trust metadata.
- Apply least-privilege to the Doris account used by CocoIndex, limiting its ability to modify unrelated schemas or tables.
How teams detect issues like this
Organizations can detect and monitor this class of flaw using a combination of code-level and operational techniques:
- Static analysis: Flag string concatenation used to build SQL statements, especially where identifiers and keywords are assembled from external or dynamic inputs.
- Code review: Look for custom SQL-building logic in connectors, particularly around DDL operations (ALTER TABLE, CREATE TABLE) that use variables for table or column names without validation.
- Logging and monitoring: Enable detailed SQL logging in staging or controlled environments to spot anomalous or multi-statement ALTER TABLE queries derived from unexpected table names.
- Policy enforcement: Incorporate secure coding rules into CI pipelines that disallow ad-hoc SQL string construction for schema changes when safer abstractions or validation utilities are available.

