Topic 2 of 5 · 4 min read
Separate identities for agents and humans
Goal: Design an agent identity whose actions show up separately in audit logs and cannot exceed the user it acts for.
An agent should act as itself, with its own identity, and when it acts for a person it may use only the rights that person has. If the agent signs in as you, every log line says "you did it", and nobody can tell your actions from the agent's.
Check yourself · 1 of 3
Why give an agent its own service account instead of using an employee's login?
Why it matters
Two problems appear when agents borrow human identities. First, attribution: after an incident you cannot tell which changes a person made and which an agent made. Second, over-reach: a shared service account often holds more rights than any single user. The agent then does for a junior employee what that employee was never allowed to do. This is the confused deputy problem, and the MCP security guidance describes it for servers that act on behalf of users.
How to do it
- Create a distinct identity per agent. A service account, workload identity or bot user, named for what it does:
docs-review-agent. Never share one across agents. - Give that identity its own minimal grants. Treat it as a new hire with a narrow job.
- When acting for a user, delegate, don't impersonate. Use on-behalf-of flows such as OAuth token exchange (RFC 8693), where the new token records both the user and the acting agent.
- Take the intersection of rights. The effective permission is what the agent is allowed AND what the user is allowed. The agent never gains rights from a user, and a user never gains rights through the agent.
- Check on the server side. The API enforces the limits for every call. The prompt saying "only read files the user owns" is not enforcement.
- Log both parties. Every action records the agent identity, the user it acted for, the tool, the target and a request id.
Before and after
Before: support-bot uses one shared admin service account.
Log: "admin@acme refunded order 8841"
After: support-agent acts on behalf of agent user dana.
Log: "support-agent (for dana) refunded order 8841 within dana's refund limit"
In the first log nobody can tell who or what acted. In the second, the log names both, and the refund cannot exceed Dana's own limit.
What goes wrong
- Shared accounts. One identity across five agents means one revocation breaks them all, and one leak exposes them all.
- Token passthrough. The agent forwards the user's token to another service. The downstream service cannot tell who really called.
- Rights by union. The agent's wide grants plus the user's rights give a combination nobody approved.
- Impersonation for convenience. Logging in as the human saves setup time and erases the audit trail.
Examples
Intersection of rights
Agent triage-agent may read and label tickets. User Ravi may only see tickets of the Billing team.
triage-agent for ravi -> read ticket 77 (Billing): allowed
triage-agent for ravi -> read ticket 90 (HR): denied, Ravi cannot see it
triage-agent for ravi -> delete ticket 77: denied, the agent cannot delete
The agent gains nothing from Ravi, and Ravi gains nothing from the agent.
Reading an audit trail
2026-11-02T10:14Z actor=ci-bot acting_for=maya action=merge repo=api tells you the agent, the person, the action and the target. Without actor, this line would just say "maya merged", and the agent would be invisible.
Key points
- Give every agent its own identity so its actions are logged separately from people.
- Use delegation that records both the user and the agent, not impersonation.
- The effective rights are the intersection of the agent's grants and the user's rights.
- Enforce limits in the service that receives the call, not in the prompt.
- Never share one service account across several agents.
Common mistakes
- Running the agent under a human's login so logs show only the person.
- Using one all-powerful service account for every agent and workflow.
- Passing the user's own token through to downstream services.
- Trusting a prompt rule such as "only touch the user's own data" in place of server-side checks.
Check yourself · 2 of 3
An agent acts for user Mia. Mia can read all invoices. The agent is granted read access to only one customer's invoices. What can the agent read for Mia?
Check yourself · 3 of 3
An audit log says only "admin refunded order 8841". The refund was made by an agent. What is the root problem?
Practice items, not counted towards your mastery.
Start here
- OWASP AI Agent Security Cheat Sheet (opens in a new tab)ArticleFree
Practical controls for agent tools, permissions, human approval and monitoring.
- LLM06: Excessive Agency (OWASP Gen AI Security Project) (opens in a new tab)StandardFree
Names excessive functionality, permissions and autonomy as the root causes, with mitigations.
- GitHub Docs: Managing your personal access tokens (opens in a new tab)DocsFree
How fine-grained tokens limit repositories, permissions and lifetime.
More for this topic
- RFC 8693: OAuth 2.0 Token Exchange (opens in a new tab)StandardFree
The standard for delegation: swapping a user token for a narrower token that names the acting party.
- MCP security best practices (opens in a new tab)DocsFree
Scope minimisation, confused-deputy and token-passthrough risks for MCP servers.