Keeping AI agents in bounds: the security controls that matter most
An agent that can act can act wrongly, or be steered by someone else. Eight principles that keep an agent inside a configurable system no more dangerous than the person it works for.
Key takeaways
- An agent receives exactly the permissions of the person it acts for, checked in the same layer as the user interface.
- Work with a few named permission sets, presets, secure-by-default inheritance and separate rights for risky actions.
- Cap how deep chains of agent-triggered changes can go, so agents cannot keep triggering themselves.
- Pin and verify shared code, run user logic in bounded sandboxes, trace every step, and get the infrastructure basics right.
The value of AI agents shows up when they do real work inside your systems: reading data, changing configuration, starting processes. So does the risk. An agent that can act can also act wrongly, and an attacker who manages to steer it gets everything it is allowed to do.
Configurable systems, where business rules, processes and data are defined through configuration rather than code, suit agents well: the agent uses the same building blocks a person would. Below are the principles we follow when agents get that kind of access, and why each one matters more now that attackers rely on automation and AI as well.
1. An agent gets exactly a person’s permissions, checked in the same place
The most important decision of all: authorization checks belong in the layer that both the user interface and the agent’s tools call. Not in the front end, and not in a separate “AI” path. An agent acting for a user should be able to do exactly what that user could do in the browser, and nothing beyond it. More on this in opening configurable systems to AI agents.
The tempting shortcut is a service account with broad rights for the agent integration, “to keep things simple”. That turns every prompt injection into an admin action.
2. Least privilege that people can keep up with
Fine-grained permissions only help if people can keep them correct. What works in practice:
- Bundle permissions into a few named sets and grant them through your existing identity process, so access is reviewed where everything else is.
- Presets such as read-only, edit and full make the safe option the easy one.
- Secure by default: anything new inherits the protection of the place it was created, so nothing starts out open.
- Keep risky actions separate, such as making something live in production or adding executable code, from ordinary editing.
3. Fail safe
Permission changes should take effect only once committed, so a change that gets rolled back never grants access. Calls to an external authorization service will sometimes fail; retry them, record failures durably and alert on them rather than losing them quietly. And make sure no malformed or unexpected entry can ever lock everyone out, or let everyone in.
4. Keep agents from triggering themselves forever
Agents are often started by events, including “something changed”. An agent that changes things can then trigger itself, or another agent that triggers the first one again. Track how deep a chain of agent-triggered changes goes, and stop it past a small limit. Without that, one bad prompt turns into an endless, very fast loop of changes.
5. Code that agents can run is pinned and verified
If agents or users can call shared code, pin exact versions that never change after publication, and check every binary dependency against its checksum before loading it. That way nobody can quietly swap a library under a running process.
6. Sandboxed, bounded execution
User-defined logic should run in isolated, bounded runtimes (see running user scripts on GraalVM), with values passed in as parameters rather than pasted into the code. That removes a whole class of injection, stops one slow or hostile script from starving the rest, and turns resource exhaustion into a metric instead of an outage.
7. Every step leaves a trail
Trace every agent step: what ran, with which input, what it decided and what it changed. When something goes wrong, whether through a bug, a confused model or an attacker, you have to be able to reconstruct exactly what happened. Keep tracing off the critical path, so it is never the first thing switched off under load.
8. Infrastructure basics still decide most of the outcome
None of the above helps if the platform around it is open:
- no admin endpoints reachable without authentication, and diagnostic endpoints that dump memory turned off;
- network policies that restrict where each workload may connect;
- secrets kept in a secret store, rotated, and never written to logs;
- staging held to the same standard as production;
- endpoint detection on every node, checked to be actually reporting.
A quick test for your own agent setup
- If someone injects instructions into data your agent reads, what is the worst thing the agent is allowed to do?
- Are the agent’s permissions checked by the same code as a person’s?
- Can an agent trigger itself, directly or through another agent?
- Could you reconstruct every action an agent took last Tuesday?
If any answer feels uncomfortable, start there.
FAQ
What permissions should an AI agent have?
Exactly those of the person it acts for, and no more, checked by the same code that protects the user interface. A broad service account turns every successful prompt injection into an admin action.
How do I stop AI agents from triggering each other in an endless loop?
Attach a depth counter to every change an agent makes and every event it causes, and drop events past a small limit. One bad prompt then cannot grow into an endless chain of changes.
What is the biggest security risk of agentic AI?
Prompt injection combined with broad permissions: instructions hidden in data the agent reads make it work for an attacker. Narrow permissions decide how much harm a successful injection can do.
Is securing the agent enough?
No. Unauthenticated admin endpoints, open networks, secrets in logs or a weaker staging environment undo every control at the agent level. The infrastructure basics still decide most of the outcome.
Securing an agent platform is not a single feature. It is a series of plain, consistent decisions that keep the agent no more dangerous than the person it acts for. We would like to hear how you approach it: what has worked, and what has caught you out.
