/

CVE-2026-32628

Severity:

HIGH RISK

(8.8)

SQL Injection in AnythingLLM SQL Agent Database Connectors

CVE-2026-32628

Analyzed

Vulnerability type

Category:

SQL Injection

CWE:

CWE-89

Impact:

Arbitrary SQL Command Execution on Connected Databases

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

A SQL injection vulnerability in the AnythingLLM built-in SQL Agent plugin allows arbitrary SQL command execution on connected databases when constructing table schema queries.

Any user who can invoke the SQL Agent can supply crafted table names that are concatenated directly into queries, potentially leading to data exfiltration, corruption, or escalation within the database.

Affected context

This vulnerability appears in AnythingLLM deployments that:

  • Enable and use the built-in SQL Agent plugin, and
  • Connect the agent to relational databases (MySQL, PostgreSQL, or MSSQL), and
  • Allow users or integrators to influence or provide table names the agent uses for schema inspection.

The issue manifests in the getTableSchemaSql() method across all supported database connectors, where table names are interpolated into SQL statements without safe handling.

Exploit preconditions

  • Attack surface: AnythingLLM SQL Agent interface (UI, API, or any feature that triggers the SQL Agent).
  • Required access: Ability to invoke the SQL Agent plugin and influence the table_name value (directly or indirectly via prompts or inputs).
  • Trigger point: Execution of getTableSchemaSql() when the agent attempts to gather table schema information using the attacker-controlled table name.
  • Why exploitation is possible: The SQL query string is constructed using direct string concatenation of the untrusted table_name parameter, with no sanitization or parameterization, allowing injected SQL to be interpreted by the database engine.

Why this happens

The underlying bug is a classic SQL injection pattern where untrusted input is integrated into SQL statements through string concatenation.

The getTableSchemaSql() method in each connector (MySQL, PostgreSQL, MSSQL) builds schema-inspection queries by directly appending the table_name parameter without proper quoting, escaping, or parameter binding.

This aligns with CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection'), in which attacker-controlled data is treated as part of the SQL grammar rather than as data, enabling arbitrary query modification.

Potential impact

  • Read access to sensitive tables and records that the application's database user can query
  • Modification or deletion of database records, potentially corrupting LLM context or application state
  • Creation or alteration of database schemas (tables, views, or functions), depending on granted privileges
  • Abuse of stored procedures or database-specific features that could lead to further compromise
  • Lateral movement within the data layer if shared accounts or cross-database links are present

General mitigation guidance

Effective mitigation centers on treating all table identifiers and query parameters as untrusted and separating data from SQL logic.

Recommended patterns include:

  • Using parameterized queries or prepared statements wherever possible, including for schema-related queries
  • Applying strict input validation and allowlists for table names and other identifiers before constructing SQL
  • Using database abstraction layers or query builders that handle identifier quoting and parameter binding safely
  • Restricting the database user account used by the SQL Agent to the minimum required privileges
  • Introducing a controlled mapping between user-facing names and actual table identifiers to avoid direct user control over SQL identifiers

How teams detect issues like this

Detection can rely on a combination of code-centric and operational approaches:

  • Static analysis rules that flag string concatenation in SQL construction, especially around schema inspection functions such as getTableSchemaSql()
  • Manual code review focused on database connector implementations, looking for unparameterized query building and direct interpolation of variables like table_name
  • Security-focused linters or SAST tools integrated into CI pipelines to enforce policies against dynamic SQL without parameterization
  • Database monitoring and logging for anomalous queries, unexpected schema operations, or patterns typical of SQL injection attempts

Sources

SourceLink
github.comgithub.com/Mintplex-Labs/anything-llm/commit/334ce052f063b53a4275518cbed3bab357695d7e
github.comgithub.com/Mintplex-Labs/anything-llm/security/advisories/GHSA-jwjx-mw2p-5wc7

Frequently asked

questions

Yes, if the SQL Agent is exposed through a web UI or API and remote users can trigger it and influence the table name input, exploitation can occur over the network.

An attacker needs the ability to invoke the SQL Agent plugin and cause it to issue schema queries with attacker-controlled table names. This might be through direct access to the agent interface or via any feature that passes user input into the agent.

Refactor the database connector code so that all SQL queries, including schema introspection queries, use parameterized statements or safe identifier-quoting APIs, combined with strict validation or allowlisting of permissible table names.

Establish development guidelines that prohibit constructing SQL using raw string concatenation with untrusted input, enforce use of database abstraction layers or parameter binding, and add automated static analysis checks to flag unsafe SQL construction patterns before code is merged.

Find out what's already
exploitable in your codebase.