Guides
Practical, no-fluff writing on AI agent security — how the attacks work and how to defend against them.
Start with the attack, or with the control
New readers usually arrive with one of two problems: something attacked their agent, or something made them realise nothing would stop an attack. The guides split along the same line. If you are here because of a threat, start with what prompt injection is and how to contain it in production, then read how agents exfiltrate data and its companion, how to stop your agent leaking secrets. The bulk-export variant gets its own guide: stopping bulk data export, and the destination side of the same problem is covered by egress allowlist patterns.
If you are here to build the controls before an incident prices them for you, the order we recommend is permissions first: agent permission scoping and keeping API keys out of agent context shrink what any single failure can reach. Then detection: canary tokens, where to plant them, velocity anomaly detection, and the census work in finding shadow AI agents. Then the response shelf: quarantine, the kill switch guide, the first-24-hours response plan, the 3 AM runbook, credential rotation after a compromise, and the postmortem template that turns the incident into policy.
Framework-specific guides sit underneath the general ones: securing a LangChain agent, the n8n security checklist, and MCP server security, including the tool-hijacking pattern named in what is agentjacking? The governance shelf covers policy enforcement, human approval queues, data boundary rules, audit trails, audit evidence, spend caps, and red-teaming your own agent. If a term is new, begin with what a rogue AI agent is.
How these guides are written
Every guide is written from the operating side of the controls it describes. Rogue-Agent Defense runs a policy boundary for AI agents: tool calls are checked against written policy, outbound destinations are allowlisted, canary tokens sit inside the data agents can reach, and approvals, quarantine and a kill switch handle the cases policy cannot decide alone. The guides describe those mechanics as we run them, including the places where a control does not work and a different layer has to carry the weight. Worked examples use invented companies and are labelled as worked examples; the attack techniques are the published ones, drawn from the research listed below. Nothing here is legal advice, and nothing asks you to take our word for a control: each guide ends in steps you can run against your own agent this week.
The through-line is a refusal to treat the model as the security layer. A language model cannot reliably separate instructions from data, and no prompt wording changes that. So the guides put the enforcement in deterministic machinery around the model: per-action verdicts, destination allowlists, spend and velocity ceilings, and logs that survive the incident. If a guide recommends a control, it also says what the control costs: latency in an approval queue, an afternoon of allowlist tuning, a monthly kill-switch rehearsal. Controls with hidden costs get disabled in production, and a disabled control is worse than an honest gap.
A first-week reading path
Day one: the two definition guides, prompt injection and rogue agents, so the vocabulary is settled. Day two: permission scoping and API-key custody, the two cheapest risk reductions on the shelf. Day three: plant your first canary tokens and turn on egress logging in observe mode. Day four: write the first version of your allowlist from that log, and set spend and velocity ceilings from your real baselines. Day five: draft the quarantine and kill-switch procedure, then rehearse it once on a staging agent while everyone is awake and nobody is frightened. The guides are written to be usable in that order, and each one links the next.
Weeks two to four: from controls to a system
Week two is tuning. Your allowlist has a week of real traffic behind it, your canaries are planted, and the approval queue has started collecting the gray cases. Expect the queue to be noisy at first: that noise is the map of where your written policy and your agent's real job disagree, and each resolved case makes the policy truer. The velocity and spend baselines need the same treatment: set them from observed rhythm, not from a vendor's defaults, or you will train the team to ignore the alerts within a month.
Week three is rehearsal. Run the red-team set against your own agent and score it the honest way, by executions, not by how rude the chatbot sounded. Then run the incident you most fear, on staging, with the runbook in hand: quarantine, evidence preservation, credential rotation, notification. Time each step. The gaps you find, a missing log field, a kill switch nobody can reach from a phone, are the cheapest findings you will ever get, because the alternative is finding them at 3 AM with data already leaving.
Week four is evidence. Assemble the pack an auditor, an insurer, or your largest client will eventually ask for: the agent inventory, the policy as enforced, a sample of the audit trail, the approval records, and the incident file from your rehearsal. The compliance evidence guide on this index lists the five packs and what belongs in each. Teams that build the pack in week four answer inquiries with a link. Teams that build it during the inquiry answer with a project.
Frequently asked questions
What is a rogue AI agent?
An agent acting outside the policy its owner set for it: calling tools it should not call, sending data to destinations nobody approved, working at hours and speeds nobody scheduled, or following instructions that arrived from the environment instead of from its owner. It is almost never a model deciding to rebel; the realistic causes are a prompt injection that stuck, a mis-scoped credential, or an unguarded edge in the task definition.
Can prompt injection be fully prevented?
No known method prevents every prompt injection attack today, and that is OWASP's own assessment. Teams reduce the risk by limiting what the model can do, isolating untrusted content, checking outputs, and requiring human approval for sensitive actions. Design for containment, not for a perfect filter.
Where do I start if my agent reads untrusted content?
Inventory which of your agents read untrusted content (web, email, documents, tool outputs) and which have outbound tools. Any agent sitting at that intersection gets input scoring, an egress allowlist, and an approval gate on outbound actions first.
Sources
- OWASP Top 10 for LLM Applications (2025) — the risk catalogue these guides' controls are mapped against.
- NIST AI Risk Management Framework 1.0 (AI RMF 1.0, 2023) — the governance framework behind the inventory, oversight and monitoring practices in these guides.
- MITRE ATLAS, Adversarial Threat Landscape for Artificial-Intelligence Systems (2021, living knowledge base) — the adversary-technique knowledge base for AI systems that the attack guides draw from.
What Is Prompt Injection? A Plain-Language Guide for Agent Owners
Direct vs. indirect injection, why agent tools make it dangerous, and the layered defenses that hold.
2026-10-11 · 9 min read
How to Stop Your AI Agent From Leaking Secrets
How data exfiltration happens through agents, why system prompts don't stop it, and the boundary defenses that do.
2026-10-11 · 9 min read
Canary Tokens for AI Agents: Early-Warning Tripwires
Fake secrets planted where agents work — when one fires, you know something went rogue. Deployment guide.
2026-10-11 · 9 min read
Policy Enforcement for Autonomous Agents: Approvals, Quarantine, and Kill Switches
Stop trusting the model and start policing actions: allow/approve/deny gates, quarantine, and kill switches.
2026-10-11 · 9 min read
Agent Permission Scoping: Give Your AI Agent the Smallest Possible Keys
Excessive agency (OWASP LLM06) turns a confused agent into a dangerous one. The least-privilege playbook: scoped tokens, read/write splits, network allowlists, spending caps.
2026-10-13 · 9 min read
Hackers Turned Supermarket Freezers Into Ovens — IoT Lessons
Hundreds of French supermarkets lost tens of millions of euros when hackers remotely defrosted internet-connected refrigeration. Attack breakdown and IoT defense checklist.
2026-10-13 · 8 min read
How AI Agents Exfiltrate Data: The Egress Points
Agent data leaves through five egress points — the chat reply, tool-call URLs, outbound tools, encoded content, and the patient multi-turn ask. The taxonomy, and where each exit gets policed.
2026-11-06 · 8 min read
What Is a Rogue AI Agent? Signs Yours Has Gone Off-Policy
A rogue agent is not a sci-fi event — it is an agent acting outside its policy: strange destinations, off-pattern tool calls, canary touches. The signs, and what to do in the first hour.
2026-11-06 · 7 min read
AI Agent Egress Control: Allowlist Patterns That Work
Default-deny is the start, not the design. Five allowlist patterns that hold in production — per-tool binding, data-class rules, quarantine lanes — and the two that quietly fail.
2026-11-06 · 8 min read
AI Agent Incident Response: The First 24 Hours After a Rogue Action
The first hour decides the incident: quarantine the agent, preserve the trail, scope the blast radius from its own logs, rotate what it could touch, notify with facts — then turn the 24-hour review into new policy.
2026-11-13 · 8 min read
How to Kill Switch an AI Agent Before It Causes Damage
A kill switch for an AI agent is more than an off button: what it must halt, revoke and preserve, how fast it has to act, and how to test it before an incident tests it for you.
2026-11-14 · 8 min read
How to Quarantine an AI Agent Without Losing the Evidence
Quarantining an AI agent means stopping its hands while keeping its memory: what to freeze, what to revoke, what to read first, and when a quarantined agent may come back.
2026-11-14 · 8 min read
How to Rotate Credentials After an AI Agent Compromise
After an agent incident, rotate everything the agent could touch — not just what it used. The order, the session trap, the canary shortcut, and how to prove the old keys are dead.
2026-11-14 · 8 min read
AI Agent Audit Trails: Exactly What to Log So an Incident Is Answerable
An audit trail that cannot answer what left, to where, starting when is decoration. The seven event families to log, the fields each one needs, and how long to keep them.
2026-11-14 · 8 min read
How to Red-Team Your Own AI Agent Before Someone Else Does
Red-teaming an AI agent means attacking its actions, not its chat: the five attack families to run, how to score a pass honestly, and how to turn failures into policy.
2026-11-14 · 8 min read
MCP Server Security for AI Agents: How Tool Servers Get Abused
An MCP server hands your agent new tools and new trust. The abuse patterns — poisoned tool descriptions, silent tool swaps, over-broad servers — and the checks that contain them.
2026-11-14 · 8 min read
How to Contain Prompt Injection in Production (Not Just Detect It)
Detection tells you an injection happened; containment decides what it costs. The four containment layers — instruction hygiene, action policy, egress control, blast-radius limits — in production order.
2026-11-14 · 8 min read
AI Agent Sandboxing: What to Isolate, and What a Sandbox Cannot Do
A sandbox limits where an agent runs; it does not decide what the agent may do. How to sandbox file, network, code and credential access — and the policy layer a sandbox still needs.
2026-11-14 · 8 min read
AI Agent Spend Caps: How to Stop a Runaway Agent From Burning Your Budget
A looping or steered agent spends money at machine speed. Per-run, per-day and per-task caps, the cost-spike signals that precede the bill, and how to set numbers that bite.
2026-11-14 · 7 min read
n8n AI Agent Security Checklist: Lock Down a Workflow Agent Before It Acts for You
n8n agents act through credentials stored in workflows and webhooks anyone can guess. A practical lockdown checklist: credentials, webhook exposure, tool scope, approvals and spend — in build order.
2026-11-14 · 8 min read
Human Approval Queues for AI Agents: What to Hold, What to Let Run
An approval queue fails two ways: holding everything until humans stop reading, or holding nothing that matters. How to choose the held actions, design the approval screen, and keep reviewers sharp.
2026-11-14 · 8 min read
Where to Plant Canary Tokens So a Rogue Agent Reveals Itself
A canary only works where a rogue agent will touch it and a legitimate workflow never will. Placement strategy by surface: credential stores, databases, documents, mailboxes and memory.
2026-11-14 · 7 min read
AI Agent Data Boundary Rules: What Data May Go Where, Written Down
Data boundaries turn a vague do not leak anything into enforceable rules: classify the data, name the destinations, bind them per agent — with examples you can copy into policy.
2026-11-14 · 8 min read
How to Stop an AI Agent From Bulk Exporting Your Data
Bulk export is how agent incidents become breaches: one call, thousands of records. Thresholds, staged approvals, per-run volume budgets and the patterns that reveal a sweep in progress.
2026-11-14 · 7 min read
AI Agent Incident Postmortem: A Template That Produces Policy, Not Paperwork
A good agent postmortem converts one incident into boundary rules. The template: timeline from the trail, door analysis, blast-radius maths, and the policy-patch table with owners and dates.
2026-11-14 · 8 min read
AI Agent Compliance: What Evidence an Auditor Actually Wants to See
When an auditor asks how your agents are controlled, screenshots of a prompt will not do. The five evidence packs — inventory, policy, trail, approvals, incidents — and how to produce them as by-products.
2026-11-14 · 8 min read
How to Find Shadow AI Agents Running in Your Company
Shadow agents are the ones nobody registered: a script with a key, a workflow with a founder's token, a bot in a team channel. Where they hide, how to surface them, and what to do with each one you find.
2026-11-14 · 8 min read
AI Agent Velocity Anomalies: When Speed Itself Is the Attack Signal
Loops, sweeps and bursts share one fingerprint: rate. How velocity baselines work, which rate guards to set — velocity, burst, off-hours, fail-streak — and how to act on them without paging for trivia.
2026-11-14 · 7 min read
How to Stop an AI Agent From Deleting Data It Should Not
Deletion is the one agent action with no undo worth trusting. Soft-delete defaults, approval gates with counts, destructive-action guards and restore drills — the layered answer.
2026-11-14 · 7 min read
The On-Call Runbook for a Rogue AI Agent at 3 AM
The runbook an on-call engineer can execute half-asleep: the first five minutes, the decision tree for quarantine versus kill, who to wake, and the exact note to leave for morning.
2026-11-14 · 7 min read
How to Secure a LangChain Agent in Production
LangChain agents chain tools with the credentials of the process that hosts them. Production hardening: tool allowlists, callback-level policy checks, output handling and tracing that doubles as an audit trail.
2026-11-14 · 8 min read
How to Keep API Keys Out of Your AI Agent's Context Window
Anything in the context window can be repeated, summarised or smuggled out. Broker patterns, just-in-time credential injection and secret scanning that keep keys usable but unreadable.
2026-11-14 · 7 min read
What Is Agentjacking? When Attackers Hijack an Agent Through Its Tools
Agentjacking is the takeover of an agent's actions via its tool layer: poisoned tool outputs, swapped tools and malicious servers. How it differs from prompt injection, and the controls that break the chain.
2026-11-14 · 8 min read
How to Stop an AI Agent From Looping Forever (and Billing You for It)
Agent loops are decision loops, not code bugs: the agent keeps choosing to retry. Iteration ceilings, progress checks, fail-streak breakers and the spend walls that end them.
2026-11-14 · 7 min read
Multi-Agent Contagion: How One Compromised Agent Infects the Rest
Agents that share memory, tools and message channels share fate. How injections spread between agents, why shared context is the transmission medium, and the quarantine geometry that stops it.
2026-11-14 · 8 min read
Cyber Firms Are Turning Away Hack Victims — What Now?
Incident-response firms are turning away hacked companies, Reuters reports, as AI-driven attack volume outruns human responders. What to do if it happens to you.
2026-11-30 · 8 min read
📋 Free resources
Prompt Injection Defense Cheat Sheet — the 7 attack families, 5 defenses, 60-second self-check. Free one-page PDF, no signup.
2026-10-13 · cheat sheet