/

CVE-2026-32622

Severity:

HIGH RISK

(8.8)

Prompt Injection / LLM-Assisted Code Generation Abuse

CVE-2026-32622

Analyzed

Vulnerability type

Category:

Prompt Injection / LLM-Assisted Code Generation Abuse

CWE:

CWE-20, CWE-74, CWE-77, CWE-862

Impact:

Remote Code Execution via LLM-Generated SQL

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

SQLBot versions 1.5.0 and below contain a stored prompt injection flaw where attacker-controlled terminology descriptions are injected into the LLM's system prompt without effective validation or fencing.

When combined with a missing permission check on the Excel upload API and unsafe handling of generated SQL, this allows an attacker to steer the LLM into emitting dangerous PostgreSQL commands that can lead to remote code execution under the postgres user.

Affected context

This vulnerability affects SQLBot deployments that:

  • Enable the Excel upload API for terminology or business glossary management
  • Allow LLM-generated SQL to be executed (or semi-automatically approved) against a PostgreSQL database
  • Inject uploaded terminology descriptions directly into the LLM's system or context prompt

It becomes risky in environments where authenticated users can upload terminology and where the LLM has authority or strong influence over SQL statements run against production databases.

Exploit preconditions

  • Attack surface: SQLBot web/API interface, specifically the Excel terminology upload endpoint.
  • Required access: Any authenticated user account with access to the upload feature; no special admin role is required when the permission check is missing.
  • Persistent vector: Malicious terminology and descriptions stored server-side and reused across LLM sessions (stored prompt injection).
  • Trigger point: When the LLM composes answers and the stored terminology is injected into its system prompt or context before SQL generation.
  • Why exploitation is possible:
  • The Excel upload API does not enforce proper authorization, allowing low-privilege users to introduce hostile content.
  • Terminology descriptions are stored without sanitization or filtering of model-directing instructions or SQL payload hints.
  • The LLM context assembly lacks semantic fencing, role separation, or escaping, so attacker content is treated as trusted instructions.
  • Generated SQL is allowed to include powerful PostgreSQL features (e.g., COPY ... TO PROGRAM) that can be executed on the database or application server.

Why this happens

The core issue is insufficient validation and governance of untrusted content that is later used as control input to an LLM tasked with generating executable SQL.

At an abstract level:

  • CWE-20 (Improper Input Validation): Terminology descriptions are accepted and persisted without validating that they are benign business metadata rather than model-steering instructions, OS command hints, or SQL fragments.
  • CWE-862 (Missing Authorization): The Excel upload API does not enforce appropriate permission checks, allowing broader-than-intended actors to populate or modify system-level terminology that influences all users.
  • CWE-74 / CWE-77 (Injection Risks): The system assembles prompts by concatenating attacker-controlled descriptions into the LLM's system prompt, which then produces SQL that may embed shell-capable constructs (e.g., PostgreSQL COPY … TO PROGRAM). Because the LLM output is treated as trusted and executed in a powerful context, this becomes an indirect injection channel.

Conceptually, the product treats untrusted user uploads as trusted policy/instructions for the LLM, without boundaries between user data and system control fields. This misclassification of trust and the absence of semantic guardrails allows prompt injection to escalate into database- and host-level code execution.

Potential impact

  • Execution of arbitrary OS commands on the database or application server under the postgres user.
  • Exfiltration of sensitive data from PostgreSQL, including application secrets, user records, and audit logs.
  • Destruction or corruption of database contents, leading to data loss or integrity violations.
  • Lateral movement from the database host into other internal services, depending on network topology and available tooling.
  • Abuse of the LLM to produce misleading or malicious query results, undermining trust in analytics and reports.

General mitigation guidance

Effective mitigation involves combining stricter authorization, robust input handling, and strong controls around model outputs that can trigger side effects:

  • Enforce strong authorization on content that shapes system prompts:
  • Treat terminology, glossaries, and configuration that feeds the LLM's system prompt as privileged configuration rather than ordinary user content.
  • Restrict modification of these artifacts to tightly controlled roles with clear auditability.
  • Constrain and sanitize untrusted content before it enters prompts:
  • Normalize terminology descriptions to a limited, non-executable format (e.g., plain text without control markers, templates, or code-like structures).
  • Apply allow-lists for acceptable patterns and lengths; reject or quarantine content that exhibits instruction-like phrasing, SQL keywords, or shell hints.
  • Encode or escape user text where possible so that the model is clearly instructed to treat it as data, not as instructions.
  • Introduce semantic fencing and role separation in prompt construction:
  • Use explicit meta-instructions that clearly separate "system rules" from "user-provided context," instructing the model never to follow instructions that originate from data fields.
  • Place user-sourced terminology in separate structured fields (e.g., tables, JSON blobs) with explicit labels like "Example data only" instead of mixing it into the core system instructions.
  • Gate and constrain model-generated SQL before execution:
  • Introduce a policy layer that inspects generated SQL and rejects dangerous constructs (e.g., COPY ... PROGRAM, CREATE EXTENSION, file system access, superuser-escalating statements).
  • Require human review or secondary automated checks for SQL that modifies schema, executes functions, or touches sensitive tables.
  • Run the database and application with least privilege, disabling or restricting capabilities that allow direct OS command execution from SQL.
  • Harden the execution environment:
  • Run PostgreSQL and any associated workers in restricted OS and container environments with minimized permissions.
  • Isolate the database from direct network access to critical infrastructure where feasible.

How teams detect issues like this

Detection strategies can focus on both the application layer and downstream SQL/database behavior:

  • Static and configuration review:
  • Inspect API handlers for upload endpoints to ensure they enforce role-based access control (RBAC) and explicit authorization checks.
  • Review prompt-building logic for direct concatenation of user-controlled fields into system prompts, particularly those that influence SQL generation.
  • Use static analysis or custom linters to flag patterns where LLM outputs are executed as SQL or shell commands without intermediary policy filters.
  • Runtime and behavioral monitoring:
  • Monitor PostgreSQL logs for unusual or high-risk commands (e.g., COPY ... TO PROGRAM, DO $$ blocks, CREATE EXTENSION, or accesses to atypical system tables).
  • Instrument the application to log the origin of terminology changes (user identity, time, source IP) and detect sudden or suspicious changes in shared terminology.
  • Watch for sharp shifts in query patterns generated by the LLM, such as unexpected write-heavy workloads or commands touching security-sensitive tables.
  • Policy enforcement and testing:
  • Implement pre-deployment tests where malicious terminology is injected in a controlled environment to validate that prompts remain fenced and dangerous SQL is rejected.
  • Use automated security testing tools that can simulate prompt injection and evaluate whether generated queries violate defined SQL safety policies.

Sources

SourceLink
github.comgithub.com/dataease/SQLBot/releases/tag/v1.6.0
github.comgithub.com/dataease/SQLBot/security/advisories/GHSA-m7q7-vhw9-q7m3

Frequently asked

questions

Exploitation is feasible wherever general authenticated users can access the Excel upload API or any functionality that populates terminology used by the LLM. Because the injection is stored, one successful upload can affect multiple subsequent sessions and users.

No. The issue arises specifically because the upload endpoint lacks proper permission checks, allowing low-privilege authenticated users to influence high-privilege LLM behavior and resulting SQL execution.

Combine strict authorization on any configuration that shapes system prompts, rigorous validation/sanitization of terminology descriptions, semantic fencing in prompt construction, and a SQL policy layer that rejects dangerous constructs before execution.

Treat all user-provided or user-modifiable context as untrusted, separate it cleanly from system instructions, clearly instruct models not to follow instructions from data fields, and enforce downstream guards (policy checks, least privilege, and monitoring) before any model-generated output can trigger actions like database modification or code execution.

Find out what's already
exploitable in your codebase.