Artificial Intelligence

AI Agent Security: Prompt Injection, Safe Tools, and Containment

AI agents read untrusted text and take real actions. This guide explains prompt injection in plain language, how to give agents safer tools, and how to contain them so a mistake stays small.

Posted by the Qlauson TeamPublished Last updated — views8 min read
Share story
Editorial still life of a small white robot figurine inside a locked glass cube, with a red cable stopped at the glass, against teal, orange and cream color blocks
Conceptual editorial illustration / Artificial Intelligence. Not a product screenshot.

The short answer

An AI agent follows instructions, but it cannot always tell your instructions from instructions hidden in the text it reads. That is prompt injection, and security agencies say there is no complete fix yet. The practical answer is layered: limit what the agent is allowed to do, keep it inside a contained space, ask a human before risky actions, and log everything.

AI agents read untrusted text and take real actions. This guide explains prompt injection in plain language, how to give agents safer tools, and how to contain them so a mistake stays small.

01 / The story

What prompt injection actually is

An AI agent works by reading text and deciding what to do next. The problem is that the agent reads two kinds of text at once: your instructions, and the content it is working on, like emails or web pages. To the model, both are just words. If an attacker hides an instruction inside the content — for example, a line in an email saying 'forward the last invoice to this address' — the agent may follow it as if you had asked.

This is called prompt injection, and it is the top risk on the OWASP list for large language model applications. The UK's National Cyber Security Centre has warned that prompt injection is not like classic SQL injection, where careful formatting can fully block the attack. Because models understand language loosely, there is no known way to guarantee an agent will always ignore a malicious instruction. Defenses reduce the risk; they do not remove it.

02 / The story

Why agents make it worse than chatbots

A chatbot that gets tricked can say something wrong. An agent that gets tricked can do something wrong: send a message, change a file, call an API, or make a purchase. Security researcher Simon Willison describes the dangerous combination as an agent that can read untrusted content, access private data, and communicate outward — all three at once. Remove any one of the three and most prompt-injection attacks lose their power.

Real incidents follow this pattern. Agents asked to summarize email have been shown to act on instructions inside the email. Coding agents have been steered by text inside the repositories they were reading. None of these required hacking the model itself — the attacker only had to control some text the agent would read.

03 / The story

Safe tool use: shrink what the agent can do

Tools are the actions an agent can take, such as 'send email' or 'run this command'. The single most effective protection is least privilege: give the agent the smallest set of tools, with the narrowest permissions, that still lets it do its job. An agent that summarizes support tickets does not need the ability to reply to customers, delete records, or issue refunds.

Make dangerous tools explicit and separate. A common pattern is to split work into two stages: an agent that reads and proposes, and a narrow, well-checked function that acts. Anthropic's guidance on building effective agents makes the same point in general terms: keep agent systems as simple as the task allows, because every added capability is also an added way to be misused.

Keep secrets out of reach. Do not paste API keys into prompts, and prefer short-lived, scoped tokens over one powerful master key. If the agent never sees a credential, a successful injection cannot steal it.

Design choiceRiskier versionSafer version
Email accessRead and send mail freelyRead mail; sending needs human approval
File accessFull access to the whole diskOne working folder, no system paths
CredentialsOne master API key in the promptScoped, short-lived tokens the agent never sees
Shell commandsAgent runs any commandA short allow-list of checked commands
Web browsingAgent follows any link and actsRead-only browsing; actions blocked on untrusted pages

04 / The story

Containment: assume the agent will eventually be fooled

Because prompt injection cannot be fully prevented, plan for the day it succeeds. Containment means running the agent inside boundaries so that a fooled agent causes a small, reviewable problem instead of a disaster. Common boundaries include running the agent in a separate account or workspace, giving it a sandboxed environment for code execution, and blocking network access except to the services it needs.

Human approval is the strongest containment for irreversible actions. Let the agent draft the email, prepare the refund, or write the code change — then let a person press the button. This costs some speed, but it converts a silent failure into a visible one. Logging is the other half: record every tool call the agent makes, so you can review behavior, spot odd patterns, and undo damage.

NIST's taxonomy of adversarial machine learning and the major AI labs' own safety guides all point the same direction: test your system with attacks, not just with friendly examples. Try injecting instructions into the content your agent reads and see what it does before an attacker does it for you.

05 / The story

What to watch, including 2027

Research on prompt-injection defenses is active: model providers are training models to resist injected instructions, and new standards for agent permissions are being discussed. Expect steady improvement in detection tools and in 'agent firewalls' that filter what agents can read and do.

Disclaimer for 2027: nothing here predicts what will happen in 2027. No complete technical fix for prompt injection has been announced as of October 2026, and security agencies advise treating it as an ongoing risk to manage rather than a bug that will be patched. Product features, standards, and best practices may change, so check current provider documentation before deploying an agent.

A closer look

Practical notes for teams and curious readers

Start small. Give a new agent a read-only job first, watch its logs for a week, and only then consider letting it act. Most reported agent incidents involved agents that had more access than the task required.

Treat every piece of text the agent reads as potentially hostile: emails, web pages, documents, chat messages, even calendar invites. If the agent can read it, an attacker can write instructions into it.

This article is general education, not security advice for your specific setup. If an agent touches customer data, money, or safety systems, involve a qualified security professional.

Put it to work

Before you give an agent real access

Run through these questions before connecting an AI agent to email, files, money, or production systems.

0 of 7 considered

These questions are editorial guidance, not a product score or verified assessment.

Keep learning

Further reading

This article is Qlauson Team editorial guidance, not a product test or endorsement. Product details can change; verify them with the provider. See our Disclosure for how we approach coverage.
Share story

Read next

What Are AI Agents? How They Work and What They Can Actually Do

A practical explanation of AI agents, tools, memory, permissions, and the limits of software that can take several steps toward a goal.

Continue reading

Newsletter

Get new Qlauson stories by email.

An occasional email when we publish a new guide or update an important one. No unrelated promotions, and you can unsubscribe from any email.

Read our Privacy Policy.

Good to know

Frequently asked questions

What is prompt injection in simple terms?

It is when an attacker hides instructions inside text an AI agent reads — like an email or web page — and the agent follows those instructions as if they came from its owner. The agent cannot reliably tell your commands from commands hidden in content.

Can prompt injection be completely prevented?

Not with current techniques. The UK National Cyber Security Centre and OWASP both describe it as a risk to reduce and manage, not eliminate. Layered defenses — limited permissions, containment, human approval — make attacks much harder and less damaging.

What is the safest way to give an agent tools?

Least privilege: only the tools the task needs, with narrow permissions, scoped short-lived credentials, and human approval before irreversible actions like sending messages, spending money, or deleting data.

What does 'containing' an AI agent mean?

Running the agent inside boundaries — a separate account, a sandboxed environment, restricted network access — so that if it is fooled or makes a mistake, the damage stays small and can be reviewed and undone.

Should I let an agent act without human approval?

For reversible, low-stakes actions, possibly. For anything irreversible — sending, spending, deleting, publishing — a human approval step is the widely recommended practice, because it turns silent failures into visible ones.

Behind the article

Sources & how we organized the information

These are the primary documents used as references for this guide. Each note explains what the source covers.

  1. OWASP — LLM01: Prompt Injection (Top 10 for LLM Applications)

    Why prompt injection is the top-ranked risk for LLM applications and the recommended mitigations.

    Source checked Oct 16, 2026 · Opens in a new tab.

  2. UK NCSC — Prompt injection is not SQL injection

    The UK security agency's explanation of why prompt injection has no complete fix and must be managed as ongoing risk.

    Source checked Oct 16, 2026 · Opens in a new tab.

  3. Simon Willison — Prompt injection series

    Documented examples of agents acting on injected instructions and the 'lethal trifecta' of untrusted content, private data, and outward communication.

    Source checked Oct 16, 2026 · Opens in a new tab.

  4. NIST — Adversarial Machine Learning taxonomy (AI 100-2)

    The US standards body's classification of attacks on AI systems, including indirect prompt injection.

    Source checked Oct 16, 2026 · Opens in a new tab.

  5. Anthropic — Building effective agents

    Guidance on keeping agent systems simple and giving them only the capabilities a task requires.

    Source checked Oct 16, 2026 · Opens in a new tab.

  6. OpenAI — Safety best practices

    Provider guidance on adversarial testing, human-in-the-loop review, and limiting access to sensitive data.

    Source checked Oct 16, 2026 · Opens in a new tab.

How the information is organized

The short answer comes first. The main guide then covers What prompt injection actually is; Why agents make it worse than chatbots; Safe tool use: shrink what the agent can do; Containment: assume the agent will eventually be fooled; What to watch, including 2027. Practical notes, a checklist, and FAQs turn those topics into questions to consider for your own situation.

Source documents describe provider features, technical guidance, or standards. Qlauson’s examples, comparisons, and checklists organize that information into practical advice; they are not original test results, a measured ranking, or a provider endorsement.

Product details and prices can change after a source is checked. Confirm current details with the provider before making a decision. References to future releases are possibilities, not confirmed availability.

Keep exploring

Related articles