Prompt injection explained: how hidden instructions steer AI agents
What prompt injection is, in plain terms
A language model takes its input as text, and it has no fully reliable way to tell the owner's instructions apart from the content it was asked to read. If a document says to ignore the previous instructions and do something else, the model may do it. That confusion is the root of prompt injection, and no single setting removes it.
The name borrows from an older attack called SQL injection, where data was mistaken for commands. The comparison helps managers see the problem. The fix in that case was to keep data and commands strictly separate. With language models that separation is harder to enforce, so the defences work in layers rather than through one fix.
Direct and indirect injection
In a direct injection, the person using the agent types instructions meant to override its rules, for example asking it to reveal its hidden instructions or to do something it was built to refuse. The risk is mostly about what the agent is allowed to do for anyone who can talk to it.
In an indirect injection, the attacker never speaks to the agent at all. They place instructions in something the agent will read later: a web page it searches, an email in a shared inbox, a file a customer uploads or a comment inside a document. Indirect injection is the more serious risk for agents, because the agent acts on content its owner never reviewed.
Real-world shapes of the attack
Injection takes many forms. The shapes below describe patterns that teams should plan for. They are not reports of specific incidents, and they are a starting point for your own test cases.
- An inbox agent reads a message that tells it to forward recent threads to an outside address.
- A research agent visits a web page with hidden text that tells it to recommend a particular supplier and save the result to the CRM.
- A document summariser reads a file where a line, styled to be invisible, asks it to change the amounts in a table.
- A support agent receives a ticket that asks it to issue a refund or change a delivery address.
- A third-party tool returns text containing instructions, and the agent treats that text as commands rather than as data.
Why a clever prompt is not enough
Many teams try to solve injection by adding a line to the system prompt telling the model to ignore instructions found in content. That helps a little, and it is worth doing, but it is not a control. Attackers can phrase instructions in ways the prompt did not anticipate, and a model can be persuaded. Treat the prompt as one layer, and put the real limits where the model cannot argue with them: in permissions, in tool design and in approval steps.
Layered defences that reduce the risk
No single measure stops every injection, so combine several. The aim is to make a successful injection cause little damage and be easy to notice:
- Limit permissions. The agent should read only the records it needs and have no path to send money or data out unless a person approves it.
- Separate reading from acting. An agent that reads untrusted content should not be the same one that sends messages or changes records.
- Require human approval for outbound and irreversible actions, such as sending an email to a customer or issuing a payment.
- Label external content. Pass web pages and emails to the model inside clearly marked blocks, and state that this content is data to analyse, not instructions to follow.
- Filter tool calls. Check outgoing destinations and fields against rules, and block any call the task has no reason to make.
- Log and alert. Record every tool call and flag unusual ones, such as a new recipient or a large export.
Test for injection before you go live
Add hostile examples to your test set. Plant instructions in sample emails, web pages and documents, and check that the agent ignores them, flags them or escalates. Include the shapes listed above and several variations, because a defence that stops one phrasing may miss the next.
Repeat these tests after any change to the prompt, the model or the tools, since a new model version can respond differently to the same hidden text. Read the model provider's current guidance on prompt injection in its official documentation, because recommended defences change over time.
How Hundred Seas helps
Hundred Seas is a product studio in Taipei. We build AI agents and AI CRM systems on Claude and on OpenAI models, and we choose the model for each task on cost, speed, quality and where the client's data has to stay. For injection risk, the permissions and approval steps around a model matter as much as the model itself, and we are a registered partner in Anthropic's Claude Partner Network and an OpenAI partner.
Our work starts with a scope step of about one week at a fixed price, which ends in a written plan, a clickable prototype and a firm quote. The build then follows in weekly releases of working software, and a monthly run plan keeps the software running and up to date.
Questions
- Can prompt injection be fully prevented?
- Not with current models, as far as published guidance shows. Models do not reliably separate instructions from content. The practical goal is to make a successful injection low in impact and quick to detect, through limited permissions, approvals, separated duties and logging. Check the model provider's current guidance before you rely on any claim.
- Is prompt injection only a problem for public chatbots?
- No. It matters most for agents that read email, web pages, customer uploads or third-party data and can also act on what they find. A private internal tool can be affected if it reads content from outside the company, so assess what each agent reads, not only who uses it.
- How would I know if my agent had been injected?
- Look for actions the owner did not ask for: a new recipient, an unexpected export, a change to a record outside the task, or output that repeats instructions from the source content. Logs and alerts are the main way to spot these, and a weekly sample review often finds what alerts miss.
- Is a warning in the system prompt enough?
- It is a useful layer but not enough on its own. A line telling the model to ignore instructions in content lowers the risk somewhat, but attackers can phrase around it. Keep it, and add permission limits and approval steps that still work when the model is fooled.
- Who should own this risk in my company?
- The business owner of the process should decide what the agent may do, and the technical team should build the controls. Someone should also be responsible for reviewing alerts and keeping the test set up to date. Naming one owner for each agent stops the risk falling between teams.