Summary
PraisonAI's PGVector and Cassandra knowledge-store backends contain a SQL/CQL injection flaw in the create_collection() path when handling caller-supplied dimensions.
By passing crafted dimension values that are interpolated into CREATE TABLE DDL, an attacker can inject arbitrary SQL or CQL tokens, potentially altering or dropping sensitive tables under vulnerable configurations.
Affected context
This vulnerability appears in PraisonAI deployments using PGVector or Cassandra knowledge-store backends where untrusted callers can influence collection-creation parameters.
Specifically, the dimension argument is accepted as an integer at the API level but not enforced at runtime, and is interpolated directly into the vector column definition of generated CREATE TABLE statements.
Environments that expose collection creation to tenants, plugins, or automation without strict validation are more likely to be affected.
Exploit preconditions
- Attack surface: Application interfaces (APIs, SDKs, admin panels) that call create_collection() for PGVector or Cassandra knowledge stores.
- Required access: Ability to invoke collection creation with a user-controlled dimension parameter (e.g., tenant-level access or misconfigured internal tools).
- Trigger point: Execution of dynamically generated CREATE TABLE DDL where the dimension value is concatenated into the vector column definition.
- Why exploitation is possible: The dimension argument, although declared as an integer, is not runtime-validated or parameterized, allowing attacker-controlled strings to be injected into SQL/CQL statements executed by the database driver.
Why this happens
The core issue is improper neutralization of special elements used in SQL/CQL commands, falling under CWE-89.
PraisonAI's create_collection() backend for PGVector and Cassandra constructs CREATE TABLE statements via string interpolation and treats the dimension as trusted, inserting it directly into the vector column definition.
Because there is no strict runtime type enforcement or parameterization for this value, attackers can supply malicious tokens (for example, closing parentheses and additional statements) that the database interprets as part of the DDL.
This pattern reflects a classic SQL injection bug: mixing untrusted data with executable query text instead of using safe bind variables and strict validation.
Potential impact
- Alteration or deletion of database tables (e.g., dropping sensitive tenant tables).
- Creation of attacker-controlled tables or schemas within the database.
- Corruption or destruction of vector store metadata and embeddings.
- Escalation of impact to other tenants sharing the same database instance.
- Potential loss of integrity and availability of application data relying on the affected knowledge stores.
General mitigation guidance
Effective mitigation focuses on eliminating string-based query construction paths for schema elements influenced by users and enforcing strict validation around numeric parameters.
Common defensive patterns include:
- Treating all user-supplied values, including dimensions and sizing parameters, as untrusted and validating them against strict numeric ranges before query construction.
- Using parameterized queries or database driver mechanisms that separate query structure from data, even for DDL where supported.
- Centralizing query builders or schema factories so that schema names, keyspaces, and sizing parameters are only derived from trusted, pre-validated sources.
- Restricting who can invoke collection creation and reducing the privileges of the database account used by PraisonAI (for example, no ability to drop unrelated tables).
- Implementing input schemas or type enforcement at the boundary (API/SDK) so that non-integer dimension values are rejected before reaching the backend.
How teams detect issues like this
Detection typically combines code-level review with runtime monitoring:
- Static analysis rules can flag string concatenation or f-string usage when constructing SQL/CQL, especially where user-controlled parameters like "dimension" appear inside CREATE TABLE statements.
- Code reviews should look for any DDL generation that interpolates untrusted values into column definitions, sizes, or constraints without strict validation.
- Security linters and SAST tools can be configured to treat any unmanaged use of SQL execution APIs with dynamic strings as a high-risk signal.
- At runtime, database activity monitoring and log analysis can surface unusual DDL patterns, such as unexpected DROP TABLE operations or schemas created from user-facing APIs.
- Policy enforcement in CI/CD (for example, blocking merges that introduce new raw SQL construction without parameterization) can reduce reintroduction of similar flaws.

