Back to blog
Security for AI Agents: Continuous Red Teaming, Governance, and Audit Trails
Engineering8 min read • Dec 4, 2026

Security for AI Agents: Continuous Red Teaming, Governance, and Audit Trails

An agent with tools is a new attack surface: prompt injection, tool abuse, least privilege, human approval for writes, and full audit trails.
Diego Velez
Diego Velez
Technical leadership

An agent with tools is a new attack surface

A chatbot that only talks can, at worst, say something it shouldn't. An agent is a different category of problem: it reads emails, documents, and web pages, and it also acts — it runs code, calls APIs, modifies records, sends messages. Every tool you give it is real capacity to act on your systems, and every piece of content it reads is input you don't control.

That changes the threat model at its root. In traditional software, dangerous input comes from the user and gets validated at the boundary. In an agent, dangerous input can come from any content the agent processes on the user's behalf: the body of an email, a page it is summarizing, a shared document, a search result. If that content contains instructions written by a third party, the model may obey them. That is prompt injection, and in its indirect version (the poison arrives in the data, not in the chat) it is the central risk of running agents today.

The honest warning, up front: there is no complete fix for prompt injection. There isn't one from any provider, with any model, with any well-written system prompt. Anyone selling you an "immune" agent is selling smoke. What does exist is the usual toolkit: defense in depth, least privilege, and damage containment. Design assuming the model will be fooled one day — and make sure that on that day the damage is small, visible, and reversible.

Continuous red teaming: attack your own agent before others do

In infrastructure, nobody waits for the first real attack to discover an open port: you scan, you audit, you test. With agents, the equivalent is red teaming: subjecting the agent to deliberate attacks and recording what holds and what doesn't.

The key word is continuous. An agent is not a binary you test once: the model changes, the prompt changes, a tool gets added, a new data source gets connected. Each change can open a hole that wasn't there last month. That is why agent red teaming looks more like security CI than an annual audit: a battery of attacks that runs on every relevant change and against production on a schedule.

What that battery must include, at a minimum:

AttackWhat it tests
Direct injectionUser instructions that try to override the system rules ("ignore your instructions and…")
Indirect injectionInstructions hidden in documents, emails, or pages the agent processes
Data leakageAttempts to make the agent reveal the system prompt, credentials, other users' data, or internal context
Tool abuseConvincing the agent to use a legitimate tool for an illegitimate purpose: deleting instead of reading, sending instead of drafting
Exfiltration through outputThe agent hiding data in its answer, in a link it generates, or in a file it creates
Limit evasionSplitting a forbidden action into small steps that individually look harmless

Every attack that succeeds becomes a permanent case in the battery — just like a regression eval — and a design fix: not just "improve the prompt," but removing a permission, adding an approval, or splitting one tool into two.

Governance: the controls that actually work are code

If injection cannot be eliminated, the design question changes: it is not "how do I keep the model from going off track?" but "what can happen when it does?" The answer lives in governance, and it has a property that prompt enthusiasts find uncomfortable: almost no effective control lives in the prompt. They live in the system around the model.

  • Least privilege per task. The agent gets only the credentials and tools the current task needs, with the shortest possible scope. An agent that summarizes email does not need send permission; one that queries a database does not need delete permission. It is the IAM least-privilege principle you already know, applied to a new subject.
  • Free reads, approved writes. Split tools into two classes: read-only tools can run on their own; tools that write, delete, send, or spend require prior human approval, with the exact action in view. This is not decorative distrust: it is the same pattern as a terraform plan before an apply.
  • Spend and step limits. A maximum budget per task and per day, a maximum number of iterations, timeouts. A manipulated — or simply stuck — agent should not be able to turn that into an open invoice or a thousand actions.
  • Ephemeral credentials, separated by environment. No long-lived master keys inside the model's context. Short-duration tokens, scoped per service, with production separated from development under different credentials.
  • System-level forbidden actions. There are operations the agent never executes, not even with approval inside the normal flow: they are done by hand, through the usual channel.

We already said it in Loop Engineering, and it applies the same here: guardrails are code, not prompts. Telling it "don't share sensitive data" in the instruction is a wish. The agent not having a tool capable of reading that data is a control.

Traceability: if it wasn't logged, it didn't happen (and that is the problem)

When a human takes a harmful action in a system, the investigation starts with the records: who, when, with what credential, from where. An agent must leave the same trail, or better:

  • A complete record of every run: the goal it received, the context it used, every decision, every tool call with its arguments, every response, and the final result.
  • An approval record: which write action was proposed, who approved it (or which automatic rule allowed it), and with what information in view.
  • A record of changes to the agent itself: the model version, prompt version, and tool set in force for each run. Without this, "it used to work" is unprovable.
  • Defined retention and access: the logs of an agent that touches sensitive data are themselves sensitive data. They get protected and retained like any audit log.

Traceability does three jobs at once: it is the debugging tool when the agent makes a mistake, the evidence when there is a security incident, and the precondition for any serious team (or auditor, or enterprise client) to accept running the system. Infrastructure learned this decades ago with audit logs and CloudTrail; with agents there is no reason to relearn it the hard way.

You already knew this: it is infrastructure security with a new subject

If you come from operating systems, almost all of the above sounds familiar, and that is the good news:

Classic practiceIts agent version
Least privilege in IAMLeast privilege per task and per tool
Change review and deployment approvalHuman approval for write actions
Resource limits and quotasToken, step, and spend budgets per task
Audit logs and access traceabilityA complete trace of the agent's decisions and actions
Pentesting and continuous scanningContinuous red teaming against the agent
Network and environment segmentationSandboxes and credentials separated by environment

The discipline is the same. What is new is the subject: a component that interprets language, that can be influenced by the content it processes, and whose "decisions" must be bounded with architecture, not with polite instructions.

Conclusion

An agent's security is not bought with a better prompt or a bigger model. It is built with what surrounds the model: a test-attack battery that always runs, permissions that don't reach far enough to do serious damage, human approvals where the action is irreversible, and a complete record of everything the agent decided and did.

At SolarDevs we build agentic systems that operate on real infrastructure — monitoring, incidents, actions on client systems — and that governance and audit layer is part of the design from day one, not a patch applied later. If you are about to give an agent real tools and want to review its attack surface with someone who runs these systems, let's talk. The review starts with a simple question: if your agent were fooled tomorrow, what is the worst it could do?

Need someone to run this?

DevOps retainers with infrastructure monitoring, CI/CD, and clear monthly packages—from $500/mo.

See pricing