In the mid-2000s, the software industry learned an expensive lesson: any place where user input meets an interpreter is an attack surface. SQL injection turned login forms into database dumps for the better part of a decade, until parameterized queries, ORMs, and secure-by-default frameworks made the flaw largely a solved problem. Twenty years later, enterprises are wiring large language models into customer support, document processing, and autonomous agents — and rediscovering the same class of vulnerability in a nastier form. Prompt injection is what happens when untrusted content is interpreted as instructions. The difference this time: there is no equivalent of the parameterized query, and there may never be one. That changes how you have to defend.

Why the comparison fits — and where it breaks down

Both flaws share the same root cause: a system that cannot reliably distinguish data from code. SQL injection worked because the database executed whatever string reached it, whether typed by a developer or a stranger. Prompt injection works because a language model processes one undifferentiated stream of tokens — system prompt, user question, and the contents of whatever web page or PDF it just retrieved all arrive as text, and text can contain instructions. The comparison breaks down at the fix. SQL had a clean structural answer: separate the query template from the values, and the class of bug disappears. LLMs have no such boundary to enforce — instruction-following is the product, not a bug in it. OWASP has ranked prompt injection as the number-one risk for LLM applications since its first Top 10 for LLMs in 2023, and it remains unsolved at the model layer. That is why every serious defense today is architectural rather than a filter you bolt on.

Table 1. Two eras, one root cause.
DimensionSQL injection (2000s)Prompt injection (now)
Root causeData concatenated into executable queriesUntrusted content interpreted as model instructions
Entry pointsForm fields, URL parameters, cookiesChat input, plus every document, email, web page, or database record the model reads
Blast radiusOne databaseEverything the agent can touch: email, files, APIs, purchases, other systems via tool calls
Structural fixParameterized queries — clean separation of code and dataNone at the model layer — defense must be architectural
Industry statusLargely solved by frameworks and secure defaultsOWASP LLM01 — the top-ranked LLM application risk, still open

Anatomy of an attack: it's the agent era that raises the stakes

Direct injection — a user typing adversarial instructions into the chat box — is the variant everyone knows, and the least dangerous. The serious threat is indirect injection: adversarial instructions hidden in content the model was going to read anyway. A resume that tells the screening bot what verdict to reach. A web page with invisible text instructing the browsing agent to forward the user's data. A calendar invite that tells an email assistant to search the inbox and exfiltrate what it finds. The user never sees the payload, and the model encounters it mid-task, wrapped in exactly the kind of content it was told to trust. Connect that model to tools — send email, call APIs, write files, browse — and a successful injection stops being a weird chatbot reply and becomes an unauthorized action taken with the user's own permissions. That is the qualitative shift from the SQL era: the interpreter now has hands.

Anatomy of an Indirect Prompt InjectionThe payload rides in on content the agent was asked to read — the user never sees it.1. Attacker plantshidden instructions in aweb page, email, or file2. Agent retrieves itduring a legitimate taskthe user requested3. Model can't telldata from instructions —payload joins the prompt4. Unauthorized actiontool call: send, fetch, write —with the user's permissions5. Impactdata exfiltration, fraud,corrupted downstream systemsTRUST BOUNDARYEverything the model reads — including your own knowledge base — sits outside it.Treat all retrieved content as untrusted input, and all model output as untrusted code.
Figure 1. Indirect injection: the payload arrives inside legitimate content, and tool access turns a bad completion into a real-world action.

The attack patterns worth threat-modeling cluster into a handful of families, each with a different failure mode.

Table 2. The attack families to threat-model.
FamilyHow it worksTypical impact
Direct injectionAdversarial instructions typed straight into the interfacePolicy bypass, off-brand or harmful output, prompt disclosure
Indirect injectionPayload hidden in retrieved content — web pages, documents, emails, RAG resultsHijacked agent behavior during legitimate tasks
Data exfiltrationInjected instructions route sensitive context out — e.g. into generated links, images, or outbound tool callsLeakage of conversation history, retrieved records, credentials in context
Tool abuseInjection steers connected tools: send email, modify records, make purchases, call internal APIsFraud, unauthorized transactions, lateral movement
Memory / knowledge poisoningPayload gets stored — in agent memory, vector stores, or KBs — and re-triggers on future sessionsPersistent compromise that survives the original session

Defense in depth: there is no single fix, so build layers

Because the model itself cannot be made injection-proof, mature teams assume some injections will land and design so that a successful one is worth little. Two principles anchor everything. Treat everything the model reads as untrusted input — including your own knowledge base, because someone else wrote what's in it. And treat everything the model produces as untrusted code — outputs that trigger actions deserve the same scrutiny as user input hitting an API. From those two principles, the practical layers follow: least-privilege tool design, isolation of untrusted content, filtering, human approval gates on consequential actions, and continuous monitoring. Each layer is imperfect; the point is that an attacker has to get through all of them.

Defense in Depth for LLM ApplicationsAssume some injections land — make a successful one worth as little as possible.1 · Least-privilege toolsscoped credentials, read-only by default, no tool the task doesn't need2 · Isolate untrusted contentmark and separate retrieved data from instructions; strip active content3 · Filter input and outputinjection classifiers, URL and recipient allowlists, output validation4 · Human approval for consequential actionssending, paying, deleting, publishing — confirm before execution5 · Monitor, log, red-teamfull audit trail of tool calls; adversarial testing every releaseEach layer is imperfect. Together they turn a clever prompt into a contained incident.
Figure 2. Five layers, from architecture (top) to operations (bottom) — an attacker has to beat all of them.
Table 3. What each defense layer actually buys you.
LayerWhat it preventsHonest limitation
Least-privilege toolsCaps the blast radius — a hijacked agent can only do what its narrowest credential allowsRequires real design discipline; convenience constantly pushes toward broad scopes
Content isolationReduces how often retrieved data is mistaken for instructionsDelimiters and markers help; none are watertight against a determined payload
Input/output filteringCatches known patterns; allowlists block exfiltration routes like arbitrary URLsClassifiers trail novel attacks — filtering is a seatbelt, not a wall
Human approval gatesStops the worst outcomes: money moved, data sent, records destroyedApproval fatigue is real — gate the consequential few, not everything
Monitoring & red-teamingFinds what got through; audit trails make incidents reconstructableOnly works if someone owns the alerts — tooling without ownership is theater

The governance frame: OWASP, and treating AI apps like the software they are

The good news is that this is no longer a niche concern with no vocabulary. The OWASP Top 10 for LLM Applications gives security teams a shared taxonomy — prompt injection sits at LLM01, alongside insecure output handling, data poisoning, and excessive agency, which is OWASP's apt name for giving an agent more tools and autonomy than its task justifies. Regulators are converging on the same expectations through a different door: the EU AI Act's requirements for robustness and human oversight, and sector rules on data protection, effectively mandate the architecture described above for high-risk deployments. The practical governance move is to stop treating LLM apps as a special category and start putting them through the same gates as any internet-facing software: threat modeling in design review, security testing before launch, pen-testing after, and an incident-response runbook that names an owner. If your SDLC would not let an unauthenticated API ship, it should not let an over-privileged agent ship either.

Where to start: the first 90 days

Most organizations do not need a research program; they need an inventory and some discipline. The first month is discovery: find every LLM-powered app in the building — including the unofficial ones — and record what each can read and what each can do. The tool list matters more than the model name. The second month is hardening the highest-risk apps: tighten tool scopes, add approval gates on consequential actions, strip or sandbox untrusted content sources, and put allowlists on outbound routes. The third month is verification: red-team the hardened apps with your own injection payloads, wire tool-call logging into your SIEM, and make LLM security review a standing item in change management rather than a one-time project.

A 90-Day LLM Security ProgramInventory first — you cannot secure the agents you don't know about.Days 0–30 · InventoryFind every LLM app —official and shadowMap what each readsand what each can doDays 31–60 · HardenTighten tool scopesApproval gates on money,messages, and deletionsAllowlist outbound routesDays 61–90 · VerifyRed-team with your owninjection payloadsTool-call logs into SIEMStanding review in change mgmtThe tool list matters more than the model name.
Figure 3. Ninety days from unknown exposure to a managed, tested attack surface.

SQL injection took a decade to tame. Start now.

The SQL injection era ended not because attackers gave up, but because the industry changed its defaults: frameworks made the safe path the easy path, and a generation of developers internalized that user input is never code. Prompt injection is earlier on the same arc, with one hard difference — the interpreter at the center of it cannot be patched into perfect obedience, and the same property that makes it vulnerable is the one that makes it useful. So the defaults have to live in your architecture instead: narrow tools, isolated content, gated actions, logged everything. Enterprises that internalize this now will ship AI capabilities their competitors are still afraid to turn on — not because they took more risk, but because they engineered it down to a size they could accept.

Ship AI that's safe to switch on

How exposed are your LLM-powered apps right now?

Apptad helps enterprises build and harden AI applications — least-privilege agent architectures, guardrails and approval gates, red-team testing, and the governance to keep it all auditable. Let's start with an inventory of what your AI can already touch.

Talk to Apptad →Explore Capabilities
Found this useful? Share it.
LinkedInX / TwitterEmail