What Is a SQL Injection Excessive Agency Attack?
An LLM-agent attack that uses prompt injection plus over-permissioned database tools to execute attacker-controlled SQL queries against backend stores.
What Is a SQL Injection Excessive Agency Attack?
A SQL injection excessive agency attack is an LLM-agent failure mode in which the agent is manipulated, via prompt injection, into emitting and executing attacker-controlled SQL against a backend database. The malicious payload arrives through a user prompt, a retrieved document, a tool output, or a user-uploaded artifact; the agent incorporates it into a generated SQL statement; the over-permissioned database tool executes it. The pattern chains OWASP LLM06 (excessive agency) with classic CWE-89 (SQL injection) and is one of the most-cited 2026 risks for data-analytics agents, text-to-SQL bots, and autonomous BI tools.
Why It Matters in Production LLM and Agent Systems
The blast radius is the database. A normal prompt injection corrupts a chat output. SQL injection in an agent stack can read, modify, or destroy customer data. Privilege boundaries you carefully built at the application layer evaporate when an LLM with broad query rights is talked into bypassing them.
The pain is concentrated in roles building data-agent surfaces. A BI-bot team ships a text-to-SQL agent connected to their warehouse; a question that looks like “show me revenue for clients matching this list” carries an injected ; DROP TABLE customers; payload in the list. A platform engineer gives an analytics agent read-only access “for safety,” then watches the agent execute pg_read_server_files because the read role still allows it. A compliance team finds out post-incident that a customer’s agent leaked another tenant’s data because a multi-tenant filter was prompted away.
In 2026 agent stacks, text-to-SQL is increasingly autonomous. The agent picks the query, executes it, summarizes the result, and acts on the summary in the next step. Each step compounds risk. Mitigation requires defense in depth: parameterized query templates, scoped database roles, pre-prompt detection, post-call SQL inspection, and runtime query allowlists.
How FutureAGI Handles SQL Injection Excessive Agency Attack
FutureAGI’s approach detects the attack at three points. Pre-prompt, the Agent Command Center exposes a pre-guardrail stage where every input passes through ProtectFlash for fast prompt-injection screening and PromptInjection for deeper analysis — catching the upstream vector before it influences SQL generation. At tool-call time, the SQLInjectionDetector security evaluator scans generated SQL for CWE-89 patterns: stacked queries, comment-injection (--), UNION-based exfiltration, system-function calls. The TextToSQL evaluator scores whether the generated SQL matches the user’s stated intent; divergence between intent and SQL is a high-quality red flag for injection. Post-call, the gateway’s traffic-mirroring and audit-log primitives capture every SQL statement executed, so an incident review can replay from injected prompt to executed query.
Concretely: a data-agent team runs a text-to-SQL agent on traceAI-llamaindex and wires the gateway to require pre-guardrail: ProtectFlash on every input and post-guardrail: SQLInjectionDetector on every emitted SQL. They also wire a TextToSQL evaluator: if the user’s question mentions “show me X” but the generated SQL contains INSERT, UPDATE, DELETE, DROP, or ALTER, the call is blocked. They build a regression Dataset of 200 known SQL-injection payloads — direct, indirect via document, indirect via column data — and run nightly evals. Database roles are scoped: the analytics agent has SELECT only, no system-function access. FutureAGI catches the injection signal; database scoping limits the blast if detection misses.
How to Measure or Detect It
SQL-injection-specific signals to wire into evaluation and runtime:
SQLInjectionDetector— security-detector evaluator that flags CWE-89 patterns in generated SQL; returns presence + severity.TextToSQL— scores intent-to-SQL alignment; mismatches between user intent and SQL operation type are a pre-execution signal.PromptInjection— upstream evaluator that catches the prompt-injection vector before SQL is generated.ProtectFlash— lightweight pre-guardrail variant for high-throughput pre-screening.- Statement-type allowlist — runtime check that only permitted SQL verbs (SELECT for analytics agents) reach the database.
- Cross-tenant access rate — count of queries crossing tenant boundaries; should be zero in multi-tenant designs.
Minimal Python — pre-execution SQL injection check:
from fi.evals import SQLInjectionDetector
detector = SQLInjectionDetector()
result = detector.evaluate(input=generated_sql)
if result.score > 0.5:
raise PermissionError("SQL injection signature detected", result.reason)
Common Mistakes
- Trusting the LLM to write safe SQL. The model is helpful, not careful. Always run a detector on the emitted SQL before execution.
- Read-only role with broad system access. Read-only is not “safe” if the role can call
pg_read_server_files,xp_cmdshell, or read system catalogs. Scope tightly. - Sanitizing user prompts but not retrieved context. Indirect injection via documents and tool outputs is the dominant 2026 vector. Treat every text the model reads as untrusted.
- No statement-type guard. Analytics agents should never emit DML or DDL. Enforce verb allowlist at the tool layer.
- Skipping multi-tenant filter checks. A model that “knows” the tenant filter is required can still drop it under prompt injection. Enforce the filter outside the model, in the query template.
Frequently Asked Questions
What is a SQL injection excessive agency attack?
It is an attack where an LLM agent with database-query tools is manipulated via prompt injection into running attacker-controlled SQL. It chains OWASP LLM06 excessive agency with CWE-89 SQL injection — the model produces malicious SQL and the database executes it.
How is it different from classic SQL injection?
Classic SQL injection exploits unparameterized strings in human-written application code. The LLM-agent variant exploits the model's flexibility — the model is convinced via prompt injection to assemble malicious SQL itself, often evading conventional input-sanitization defenses.
How does FutureAGI detect SQL injection excessive agency attacks?
FutureAGI's SQLInjectionDetector flags CWE-89 patterns in tool-call SQL. PromptInjection and ProtectFlash catch the upstream injection vector. TextToSQL evaluator scores whether generated SQL matches the user's intent — divergence is a red flag.