← Back to Blog

AI Engineering

Securing AI Agents Takes More Than Good Manners

Better behavior from agents helps, but the real fix is building systems that stay safe when that behavior fails.

We gave agents our passwords. Then we tried to teach them not to misuse them.

Early this year, an open-source AI assistant that could act on its owner’s behalf spread across the internet almost overnight. It was called OpenClaw, and people were so eager to put it to work that many handed it their passwords, access keys, and even crypto wallet details. Within weeks, attackers were going after exactly those secrets, through malicious add-ons in OpenClaw’s skill marketplace and malware built to steal its configuration files.

It was a predictable result. People were giving agents powerful, long-lived credentials to get work done, despite decades of security engineering devoted to limiting what software can access. In that sense, early agent deployments repeated old mistakes.

Better behavior from agents helps, but the real fix is building systems that stay safe when that behavior fails.

How AI security lost the plot

Security engineering has spent decades learning how to limit what software can do, even when it is compromised. Its core ideas are long established: give each user and program only the access its job requires (least-privilege access), keep programs running on the same machine walled off from one another (process isolation), split a network into separate zones so a breach in one can’t easily spread to the rest (network segmentation), and keep a record of who did what, and when (audit logs). If anything, AI agents make those lessons more important.

When generative AI arrived, attention swung almost entirely to the model itself. At the hacker conference DEF CON in 2023, I created a challenge for an event where participants tried to break AI models. The model was instructed never to give anyone full administrative control of a system, known as root access. Participants had to talk it into doing so anyway, and inevitably, someone did.

It was only an exercise, but it scared people, and the industry responded with a wave of filters and instructions meant to keep models from saying or doing the wrong thing, known as guardrails.

But a model saying “you now have root access” and someone actually having it are different things. The first is just text, while the second is authority enforced by a system outside the model. The dangerous moment comes when we connect those worlds: when an agent can execute commands or make changes, a mistake in reasoning can become a real security incident.

A chatbot’s harmful answer and an agent’s harmful action present different risks. Agents can send emails, move files, change records, and invoke tools. The surrounding system must enforce what they are allowed to do, regardless of what they say or decide.

Four things you need to secure an AI agent

Securing an agent comes down to four questions. Can the model be talked into something it shouldn’t do? Whose permissions is it using? What can it reach and run? Can you reconstruct what it did afterward? I call these behavior, identity, control, and observability, or BICO for short. Most of the industry’s attention goes to the first, but attackers go after whichever layer is weakest.

Behavior: what can the model be persuaded to do?

This is the layer guardrails address, and it still matters. An agent that reads email, documents, or web pages can be steered by instructions hidden in that content, also known as prompt injection. Imagine an agent that sorts vendor email receiving a message with hidden text telling it to forward recent invoices to an outside address. If the agent is allowed to email anyone, nothing in its permissions stops that.

It gets worse when the instruction sticks. Picture an attacker who gets a support agent to write an instruction into a ticket: every time you access customer data, also send it to this outside email address. Because the agent pulls past tickets back in whenever a related keyword comes up, that instruction keeps firing long after it was planted. It’s a ticking time bomb, and the damage might not show up until six months after the breach.

Behavioral defenses lower the odds of a bad action but can’t rule one out, so they can’t be the only layer.

Identity: whose permissions does it have?

An agent needs a distinct, auditable identity, even when acting on behalf of a person. Its authority should be explicitly delegated, limited to its task, and independently revocable. A support agent might need to read tickets and draft replies, but it doesn’t need every permission its human operator has. Short-lived, narrowly scoped credentials are safer than permanent keys with access across customers or systems. A named person should remain accountable for the agent and its permissions.

Control: what can it actually access and execute?

Even with limited permissions, an agent should run in an environment that restricts what it can reach and execute. Walled-off spaces that keep a program apart from the rest of the machine (containers and sandboxes) can help, but their protection depends on how they’re configured. A container given root access to the machine it runs on (a privileged container), with broad network access or with passwords and keys stored inside it (mounted credentials), may offer little isolation at all. The boundary must be enforced outside the model, through restrictions on files, processes, networks, and tools.

The same principle applies to the systems an agent connects to. An agent might be allowed to draft a payment instruction but not to transfer money, and the payment system enforces that limit however the agent reasons about it. And when something does go wrong, you need a way to stop it: limits on how much an agent can do in a given window, and a shutoff that works when someone pulls it.

Observability: can you reconstruct its actions?

This is where much of the new work in AI security is happening. The goal is to understand why an agent acted the way it did and what it was trying to accomplish. That comes from reconstructing the chain of decisions behind each action: what information the agent drew on, whose authority it used, which tools it called, which checks and approvals it passed, and what it changed.

In practice, that means linking an agent’s actions across the tools and systems it touches. Tying those actions together into one record, known as distributed tracing, can show which tools were called, in what order, and with what results. Rerunning the task to watch it play out again, known as replay, takes more than a trace. It may also require the model version, prompts, the documents and data the agent pulled in (retrieved context), tool responses, and the state of the surrounding systems at the time (environmental state).

That record does two jobs: after an incident, it helps reconstruct what happened, and before one, it provides evidence for evaluating how agents actually behave, which may differ from what developers expected. Exact replay may not always be possible, but useful traces and controlled reproductions make failures easier to investigate and prevent.

What traditional security only partly solves

Traditional permissions constrain what operations software may perform. An agent given a document-retrieval task might search another folder, query a database, or try a different application when the first path fails. Those steps may each be permitted, but their combination may be unexpected. The harder problem is constraining how an agent uses the access it already has.

An agent can even cause a security incident without exceeding a single permission. Imagine an agent authorized to read internal documents and send emails, and a malicious document that tells it to forward confidential information to an outside address. Reading the document and sending the email are both authorized, so every individual permission check succeeds, yet the outcome violates the user’s intent.

Improvisation is what makes agents useful, and it’s also what makes them difficult to secure. Scope permissions too tightly and the agent can’t finish the job; scope them loosely and you’re trusting it to choose well among paths no one reviewed.

Human approval looks like the answer, but I worry about how it plays out. Humans are going to be in the loop a lot, just hitting yes, go, approve, approve. An approval step people click through by reflex adds friction and barely any safety. It protects even less when the person approving sees a vague summary while the agent carries out something much broader. I’d rather have people watching the agent’s work and stepping in to correct its course than signing off on every step, an approach known as human on the loop.

Watching still needs hard limits behind it. An agent can choose how to complete a task, but it shouldn’t be able to grant itself new access or bypass an approval requirement. Boundaries should depend on risk: the impact, scope, sensitivity, and reversibility of an action. A low-risk change may proceed automatically; a payment or transfer of sensitive data may require explicit approval enforced by the system carrying it out.

Room to work, inside fixed limits

For companies deploying agents, BICO translates into four practical design decisions:

  • Behavior: evaluate how agents respond to malicious inputs, unexpected environments, and attempts to redirect their actions.
  • Identity: give each agent constrained, auditable authority that can be independently revoked, even when delegated by a user.
  • Control: enforce isolation, access limits, and risk-based approvals outside the model, with reliable ways to stop consequential actions.
  • Observability: capture the context and actions needed to reconstruct incidents, investigate failures, and test assumptions.

Secure agent deployment is an engineering problem as well as a model-behavior problem. Testing how an agent responds to malicious or unexpected inputs, known as evaluations, helps reveal how it may behave. Limits the system enforces while the agent is running, known as runtime controls, determine what it is allowed to do. Observability shows what actually happened, and a secure deployment needs all three.

At DEF CON, contestants persuaded a model to grant them root access, and the model said yes. Nothing happened, because the model had no real authority to grant. That’s a useful standard for enterprise AI.

Your agent will sometimes make the wrong decision. Your security architecture should determine how much damage that decision can do.

Stop debating AI. Start deploying it.

Get Started