Talk to us 24/7: +1 (415) 650-2548 info@tendwiseai.com Free AI tools
Call us 24/7+1 (415) 650-2548 Book a Strategy Call

Guide · 5 min read · Published

Prompt Injection: How to Keep Your AI Agents and Chatbots Safe

QUICK ANSWER

Prompt injection is when instructions hidden in a message, web page, email or document make an AI system ignore its rules. The UK's National Cyber Security Centre says it may never be fully fixed, so the practical defence is limiting the damage: give AI tools minimal permissions, keep untrusted content away from powerful actions, require human approval for risky steps and log everything.

Open padlock surrounded by scattered keyboard keys

Key takeaways

  • Prompt injection can be direct, typed by a user, or indirect, hidden in a web page, file or email the AI reads, according to OWASP.
  • The UK’s NCSC says it may never be fully mitigated, because language models don’t enforce a boundary between instructions and data.
  • Design for the day the AI gets fooled: least privilege, separated untrusted content, human approval for risky actions and full logging.
  • Be sceptical of any product that claims to "stop" prompt injection. The NCSC warns against exactly that.

What prompt injection is

A language model reads everything as text. Your instructions, the customer’s question and the web page it was asked to summarise all arrive in the same stream. Prompt injection exploits that. Someone slips in text that the model treats as a new instruction, and it does something you never intended.

OWASP, which publishes the Top 10 risks for LLM applications, splits it into two kinds. Direct injection comes from what a user types. Indirect injection hides in outside content the model reads, such as websites or files. OWASP’s examples are uncomfortably practical:

  • A support chatbot told to ignore its guidelines, query private data and send emails.
  • A web page with hidden instructions that, when summarised, makes the AI insert a link that leaks the conversation.
  • A CV with hidden prompts that steer an AI screening tool toward a favourable recommendation.

Why you can’t just filter it out

Many people treat this like SQL injection, a flaw that parameterised queries can fully fix. The UK’s National Cyber Security Centre says that comparison is dangerous. In a December 2025 blog post its CTO for architecture, Dave Chismon, wrote that language models "simply do not enforce a security boundary between instructions and data inside a prompt."

His conclusion is that prompt injection may never be fully mitigated. Blocking known bad phrases doesn’t work for long either, because attackers can rephrase endlessly. So the useful question isn’t how to stop every attack. It’s how much damage a fooled AI could do, and whether you can accept that.

Seven controls that limit the damage

These come from OWASP’s mitigation list and the NCSC’s advice. None is perfect on its own. Together they make a big difference.

  1. Least privilege. Give each AI tool only the access its job needs. A chatbot that answers product questions shouldn’t be able to read your CRM.
  2. Keep untrusted content away from powerful tools. The NCSC puts it neatly: when a model processes content from a party, its privileges drop to that party’s level. An agent that reads public emails shouldn’t also be able to send payments.
  3. Use ordinary code for the hard limits. Spending caps, allowed recipients and permitted actions belong in normal, deterministic software, not in the prompt.
  4. Human approval for high-risk steps. Refunds, payments, deletions and outbound messages get a sign-off. Our guide to approval steps for AI agents shows how.
  5. Mark outside content clearly. Label web pages, documents and emails as untrusted data. It makes attacks harder, though not impossible.
  6. Check outputs. Validate formats and block links or actions that weren’t expected before anything leaves the system.
  7. Log and test. Record inputs, outputs and tool calls, and watch for failed tool calls, which the NCSC says can signal someone probing. Test your system the way an attacker would.

A quick risk check for your own tools

Two questions sort most AI tools: does it read content you don’t control, and can it take actions? Here’s how we’d rate common set-ups.

ToolReads untrusted content?Takes actions?Risk level
Internal assistant answering from your own policiesRarelyNoLow
Website chatbot answering FAQsYes, customer messagesNoMedium
Inbox agent that drafts replies for reviewYes, incoming emailDrafts onlyMedium
Agent that browses the web and updates your CRMYes, web pagesYesHigh
Agent that reads email and can send payments or refundsYesYes, with moneyVery high: add hard limits and approval

Connecting agents to more tools, for example through Model Context Protocol, raises the stakes. Every new tool is something a fooled agent could misuse.

Where to start

Start with the high-risk row of that table. If any tool reads outside content and can also take real actions, add a human approval step and narrow its permissions this week. Then work down the list.

If you’re building something new, plan security in from day one. Our AI agent development and chatbot development teams design permissions, approvals and logging alongside the features, and an AI strategy review can map where your current tools sit on the risk scale.

Frequently asked questions

What is prompt injection in simple terms?
It’s when text in a message, web page, email or document tricks an AI system into following new instructions, such as ignoring its rules or revealing data it shouldn’t.
What is indirect prompt injection?
Instructions hidden in outside content the AI reads, like a web page or file, rather than typed by the user. OWASP lists it alongside direct injection.
Can prompt injection be fully prevented?
The UK’s NCSC says it may never be fully mitigated. The realistic goal is reducing both the chance of an attack and the damage it could do.
Which AI tools are most at risk?
Tools that read content you don’t control and can also take actions, such as sending emails, changing records or moving money. Those need the tightest permissions and human approval.

Sources

Get a realistic plan for your business

Book a free AI strategy call and we will scope your workflow with you.