Concept · No. 041 · November 26, 2026
An agent on a service account is a confused deputy by default
When an agent calls tools with its own broad credentials, every user inherits the agent's authority. The fix belongs at the tool boundary, not in the system prompt.
The idea
The confused deputy is an old security problem. A program holds authority that its caller does not, and the caller tricks it into using that authority on the caller's behalf. The classic case is a compiler with write access to a billing file, asked by a user to write its output there.
Agents recreate this shape almost by default. The agent runs with a service account that can read every ticket, refund any order or query any tenant's rows, because that was the easy way to wire up the tools. The user talking to it has far narrower rights. Whatever the model decides to do, it does with the service account's authority.
The principle that fixes it: authorization is decided by the principal the agent is acting for, enforced where the tool executes, using identity the model cannot choose.
An example
A support agent has two tools: get_order(order_id) and refund(order_id). Both call the billing API with a service token that can act on any order.
- A logged-in customer asks the agent to refund an order number they copied from a forum post.
- The order belongs to someone else. The system prompt says to act only on the user's own orders.
- The model follows the instruction most of the time. One phrasing, or one injected line in a ticket body, and it calls
refundanyway. - The billing API checks the token, sees full authority, and refunds.
The instruction in the prompt was a request, not a control. The safer design passes the customer's identity from the session into the tool layer, exchanges it for a short-lived token scoped to that customer, and lets the billing API reject the call. The model never sees or supplies the identity.
Where it breaks
Many downstream systems have no per-user authorization to delegate to. Then the check has to live in the tool wrapper, which means duplicating access rules that will drift from the source system unless something tests them.
Background and scheduled agents have no live user. Someone delegated the task, and that delegation needs to be recorded with its scope, or the job quietly runs as the service account forever.
Shared contexts are ambiguous. An agent summarizing a channel with many members is acting for whom, and can it read what only some of them can see.
Forwarding the user's token unchanged to another service is its own bug: the token was issued for a different audience. And user-scoped authority does not stop injection from using the user's own rights against them. This closes cross-principal abuse, not exfiltration.
In practice
I would treat every tool as an API endpoint with a caller, and design it that way.
- Take the principal from the authenticated session, never from a tool argument the model fills in.
- Prefer user-scoped, audience-restricted, short-lived tokens so the downstream system enforces its own rules.
- Where a service account is unavoidable, put a policy check in the wrapper keyed on principal, action and resource.
- For deferred work, store who delegated it and with what scope, and recheck at execution time.
- Log principal, agent, tool and resource on every write.
- Keep a test that asks the agent to act on another tenant's resource and expects a tool error, not a polite refusal.
If the only thing stopping an agent from acting on another user's data is the prompt, the agent's credentials are the real access policy.