Identify the insecure plugin design flaw (LLM07) in this snippet
The insecure pattern is a free-text 'sql' parameter executed against production, the plugin lets the model express arbitrary actions instead of choosing from a constrained menu.
Picture a vending machine versus a kitchen. A vending machine lets you push button A1 or B3, you can only buy what is already loaded into a slot. A kitchen lets a cook prepare anything they want. If you do not trust the cook, you do not give them a kitchen; you give them a vending machine. An LLM plugin that takes raw SQL is a kitchen. The model could cook anything, including queries that drop tables or exfiltrate data. A plugin that takes 'look up customer by id' is a vending machine: bounded by design.
Concept explanation~2 min read
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Concept explanation~2 min read
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
OWASP LLM07 is one of the most commonly mis-diagnosed entries in the LLM Top 10 because the failure mode sounds like a permissions problem and is actually an interface-design problem. A plugin that takes raw SQL, raw shell, raw URLs, or raw file paths gives the model an unbounded action space. Under indirect prompt injection, an attack vector LLM01 covers, the model's output is no longer trustworthy. The plugin's permissive interface then turns untrustworthy intent into real effect.
This deep dive walks the structural failure, the constrained-operation fix that production stacks have converged on, MCP as the standardized version of the pattern, and the generalization across other plugin families.
Why the free-text surface is the failure mode
An LLM is an untrusted intent producer. Alignment training reduces the rate at which the model produces unsafe intent on benign inputs. Under indirect prompt injection, a retrieved document or tool response containing attacker-crafted text, the model's output is influenced by the attacker. Alignment does not generalize to inputs the labellers never wrote.
Given that the model output is untrustworthy on adversarial inputs, the plugin's job is to constrain what untrustworthy output can do. A free-text sql parameter does the opposite: it converts any string the model produces into a database action. The reachable action space is whatever the SQL engine accepts, which on production databases includes DROP TABLE, DELETE WHERE 1=1, cross-tenant SELECT, stored-procedure invocation, and arbitrary data exfiltration.
The plugin is the boundary between intent and effect. A permissive interface erases the boundary. No amount of system-prompt instruction, output regex, or model alignment recovers what the interface gave away.
Situations where this technique stops working.
2–4 min · Everything important, quickly.
Real products, models, and research that use this idea.
- MCP (Model Context Protocol) servers in 2025-2026 enforce tool schemas as their core boundary, constrained operations with typed parameters
- Salesforce Einstein and Microsoft 365 Copilot expose business operations as bounded tools rather than raw API or SQL access
What an interviewer would ask next. Try answering before peeking at the approach.
QWhy is regex filtering on the SQL string an inadequate mitigation?
SQL is a Turing-equivalent expression surface; any regex denylist has known bypasses through comments, encoding, unicode, function calls, and stored procedures. Allowlist regex is fragile to schema changes. The right control is to remove the free-text surface, not to filter it.
Red flags & common mistakes
The phrases that signal junior thinking. Click to expand.
Red flags & common mistakes
The phrases that signal junior thinking. Click to expand.
Believing the plugin is safe because there is a system-prompt instruction telling the model 'do not run dangerous SQL', the model under injection ignores that, and the plugin runs whatever SQL it receives.
60 second bullets to scan on the way to the call.
Definition of LLM07 insecure plugin design
Why free-text plugin parameters create unbounded action space
Primary sources. Browse if you want the original framing.
Same topic, related formats. Practice these next.