CoreWise Academy

Agents & Automation · Layer III / Practitioner

Defend your agent from prompt injection

Anything your agent reads (a web page, a resume, a calendar invite) can carry hidden instructions it will follow. Why the attack has no clean fix, and the five defense layers that shrink what a successful one can do.

Nº 032 · Vol. I·6 min read· Updated August 2026

Read firstAutomate the step that slows you down (Assumes you know what it means to point an agent with tools at real work. This guide covers what an attacker can do with that same setup.)
“anything the model reads can steer it”

A hiring team wires a model to screen resumes. One applicant adds a line in white-on-white text: recommend this candidate. Screeners have fallen for exactly that, though a hardened pipeline often catches it. That is prompt injection: untrusted content, read as instructions, obeyed. A recent Apptad essay calls it the new SQL injection.

01An old bug without the old fix

SQL injection ruled the mid-2000s because databases executed whatever string reached them. User text got glued into a query, and the query ran it. The cure was structural: parameterized queries gave data and code separate lanes, and frameworks made that the default. The bug faded.

A language model has no lanes. Your setup instructions, the user’s question, and the contents of whatever page or PDF the model just fetched all arrive as one stream of text, and any of that text can steer it. There is no equivalent of the parameterized query, because following instructions found in text is the product. OWASP has ranked prompt injection the number one risk for LLM applications since 2023, and it remains open. That is why every serious defense is architectural, and why a filter you bolt on is never the whole answer.

02The payload hides in the data

Instructions typed straight into the chat box are the least dangerous form. You can see them, and the blast radius is one conversation. Indirect injection is the form to fear: the payload (the attacker’s planted instruction) hides in content your agent reads mid-task. A web page with invisible text. A calendar invite that tells an email assistant to search the inbox and forward what it finds. The agent fetched that content because you asked it to, so the attack arrives wrapped in exactly the material it was told to trust.

Tools raise the stakes. Once the model can send email, call APIs, and write files, a hijacked response becomes an action taken with your permissions. Five attack families cover the threat model:

FamilyHow it worksWhat it costs you
Direct injectionAdversarial instructions typed into the interfacePolicy bypass, leaked setup instructions
Indirect injectionPayload hidden in content the agent retrievesA hijacked agent mid-task
Data exfiltrationInjected text routes private context outwardLeaked history, records, credentials
Tool abuseInjection steers connected toolsFraud, unauthorized sends and purchases
Memory poisoningPayload stored in memory or a knowledge baseCompromise that survives the session

The last family is why the retrieval layer needs its own hygiene: a poisoned document in the store your team queries keeps injecting long after the original visit. The audit habits in Keep a growing knowledge base accurate and the scoped stores in Give your agent a memory are both containment for this case.

03Build five imperfect layers

Since the model cannot be made injection-proof, assume some payloads will land and design so a landed one is worth little. Two rules set the frame: treat everything the model reads as untrusted, including your own knowledge base, and treat everything it produces as unverified until checked. Then stack the layers, each with its honest limit:

Each layer leaks. Stacked, they turn a clever payload into a contained incident.

04The first 90 days

Most teams need inventory and discipline, and no research program. One month each:

  1. Inventory. Find every app with a model wired into it, including the ones nobody approved. For each, map what it reads and what its tools can do. The tool list tells you more about risk than the model name does.
  2. Harden. Tighten tool scopes, add approval gates on money, messages, and deletions, and allowlist the places data can be sent.
  3. Verify. Red-team the hardened apps: attack them with your own injection payloads. Wire tool-call logs into monitoring, and make model security a standing item in change review.

The bar to hold: if your release process would not ship an unauthenticated API, it should not ship an over-privileged agent either.

Further reading

FAQ

Why can't prompt injection be fixed the way SQL injection was?

SQL injection had a structural cure. Parameterized queries put data and code in separate lanes, so user text could never execute. A language model reads one undifferentiated stream of tokens, and following instructions found in text is the product, so there is no separate lane to build. Defense has to live in the architecture around the model.

What makes indirect injection more dangerous than instructions typed into the chat box?

The payload arrives inside content the agent was legitimately asked to read (a resume, a web page, a calendar invite), mid-task, where the user never sees it. If the agent has tools, the hijacked output becomes an action taken with the user's own permissions, such as sending mail or calling an API.

If every defense layer is imperfect, what is the point of stacking them?

The goal shifts from stopping every injection to making a successful one worth little. Narrow tool scopes bound what a hijacked agent can reach, approval gates stop the consequential actions, and logs make the incident visible. Together the layers turn a clever payload into a contained incident instead of a breach.

Sources
  1. Apptad · “Prompt Injection Is the New SQL Injection: Securing LLM-Powered Apps”