This comprehensive tutorial addresses the critical gap in AI agent identity securityβthe problem of multiple agents sharing credentials, using long-lived keys, and lacking proper audit trails. The article establishes why agent identity differs fundamentally from traditional service account management and demonstrates how to implement controls aligned with OWASP ASI03, the OWASP NHI Top 10, and NIST guidance. It matters because unsecured agent identities turn authorization into the blast radius of attacks, with enterprise machine-to-human identity ratios reaching 45:1 to 100:1.
- Agents Break Traditional IAM AssumptionsUnlike predictable workloads with fixed permissions, AI agents autonomously decide their next step, work in changing context, and create delegation chains where authority passes without verification. The article emphasizes that traditional IAM assumes one job with known location and fixed permissionsβnone of which apply to agents operating across multiple tools and contexts.
- Four Credential Sources Leak Authority DifferentlyThe article identifies inherited user tokens (allowing everything the user can do), shared service accounts (making logs indistinguishable), cached credentials (kept in memory for reuse), and long-lived static keys (valid long after tasks end) as the primary ways agents obtain authority. Each creates a different attack surface because the token outlives or outsizes the actual task being performed.
- Build an Inventory Before Any Other ControlThe article prescribes creating a register listing each agent's owner, purpose, service accounts, OAuth grants, API keys, connected systems and revocation paths. Discovery requires scanning beyond git repositoriesβMCP configuration files, collaboration tools, cloud consoles and ticket systemsβbecause GitGuardian found 24,008 unique secrets in MCP configs and 28% of incidents come from productivity tools, not code repos.
- MCP OAuth 2.1 Requires Audience Binding and No PassthroughThe spec mandates PKCE (one-time authorization proof), Protected Resource Metadata discovery, and resource indicators binding tokens to specific servers. The article emphasizes two critical rules: MCP servers must validate the token was issued specifically for them, and they must never forward tokens upstream, as passthrough creates a confused-deputy vulnerability. Plain bearer tokens with no authorization metadata mean any token holder can use any tool.
- Delegation Must Carry Both User and Agent IdentityThe confused-deputy lab demonstrates how an agent acting with only its own system-level identity can perform high-privilege actions on behalf of a low-privilege user. The fix requires passing both identities and authorizing each tool call against the human user's rights, ensuring the agent never acts with more authority than the person who started the workflow.
- Detection Signals Start With Proper Audit LoggingThe article requires audit trails capturing tool invocations, permissions granted, data accessed and outcomes, all tagged with both human user and agent identity. Detection of abuse depends on spotting pattern breaksβnew hours, new tools, new data volumesβand drift detection compares live permissions against the inventory on schedule to flag unexplained scope or keys.
- Revocation Must Be Testable and FastThe article emphasizes rehearsing agent credential revocation to identify bottlenecks, recommending it happen in minutes through disabling the service account, revoking OAuth grants, and rotating or deleting keys. Testing must confirm access really stops, not just that buttons were clicked, because cached tokens may work until expiration.
- Five Core Rules Underpin All ControlsThe article establishes these non-negotiable principles: one unique identity per agent never shared; a named owner and stated purpose for each; least privilege scoped to the task; short-lived credentials that can be revoked quickly; and delegation carrying both user and agent identity. These five rules determine whether a control actually reduces blast radius or just creates compliance theater.
Bottom line: AI agent identity security requires every agent to have its own inventoried, least-privilege, short-lived and revocable identityβand you must test revocation to confirm it works. Without these controls, a compromised agent or steered prompt can abuse cached credentials or inherited authority at scale, making identity the critical blast-radius chokepoint in agentic AI deployments.
β±οΈ 50 min Β· Intermediate Β· 2 hands-on labs
Picture the moment your manager asks which AI agents in the company can read the customer database, and who approved each one. You open the cloud console and find three service accounts called something like 'bot-prod', a shared API key in a config file, and an OAuth grant nobody remembers making. That is the gap ai agent identity security closes, and it is far more common than most teams admit.
In this Tutorial I will show you how an agent's identity differs from an ordinary service account, and why one shared key for every agent is a trap. Then we build a simple register of agents, owners, keys and grants on your own machine, and scan your own project folder for leaked secrets.
After that we look at short-lived credentials, OAuth 2.1 and MCP authorization settings, and a confused-deputy abuse in the intentionally vulnerable SecurityElites lab, where you apply the fix yourself. I will tie every control back to OWASP ASI03, the OWASP NHI Top 10 and the NIST NCCoE focus areas, so you can explain your choices to an auditor.
π― What You Will Be Able to Do
β Before You Start
- Basic understanding of OAuth and API keys
- Familiarity with what an AI agent and tool calling are
- Comfort reading JSON and HTTP requests
π In This Tutorial
- AI Agent Identity Security in One Answer
- What Is an AI Agent Identity?
- How Agents Get and Use Authority
- Threat Model: OWASP ASI03 and NHI Risks for AI Agent Identity Security
- Build Your Agent Identity Inventory
- Credentials, OAuth 2.1 and MCP Authorization for Agents
- Demo: Abusing an Over-Privileged Agent Identity
- Detecting Identity Abuse and Drift
- Practise a Drift Check and a Revocation Drill
- Defensive Recommendations and Practice for AI Agent Identity Security
- Your checklist
- What I want you to remember
- Questions people ask
AI Agent Identity Security in One Answer
I will give you the answer first, then we spend the rest of the article earning it. AI agent identity security means every agent has its own identity. That identity is inventoried, limited to least privilege, short-lived and revocable. When the agent acts for a person, the delegation carries that person's identity too, so the agent can never do more than the human who started the work.
This page sits inside our wider Agentic AI Security guide, which maps the full set of agent attacks and defences. Here we zoom in on one thread: who an agent is, what it can touch, and how that authority leaks.
Let me explain why this matters so much. OWASP lists Identity and Privilege Abuse as ASI03 in its Top 10 for Agentic Applications 2026, published on 9 December 2025. If an attacker steers an agent, the damage equals the authority the agent holds. Identity is the blast radius.
βοΈ The five rules we will build on
What Is an AI Agent Identity?
Let me start with a plain definition. A non-human identity (NHI) is any credential-bearing identity that is not a person. For an agent, that usually means a service account, an API key, an OAuth grant or an access token. Together these decide what the agent can read, change or spend.
π Words I just used
Traditional identity and access management (IAM) assumes a predictable workload. A service does one job, with fixed permissions, in a known place. Agents break that. They decide their own next step, work in changing context, and hand tasks to other agents, which creates delegation chains where authority can pass along without anyone checking it.
Scale makes it worse, and you can see it in the numbers. The OWASP NHI Top 10 (2025) reports enterprise machine-to-human identity ratios of roughly 45:1 to 100:1. Every agent you add multiplies the credentials nobody is watching. This is why ai agent identity security starts with counting what exists.
π§ Quick check
How Agents Get and Use Authority
Now let me walk the credential flow, because you cannot secure authority you cannot trace. The agent decides to call a tool. The tool needs proof of permission. A token is issued or reused, the tool accepts it, and the action runs. Each hop is a place where authority can be too broad or can leak.
- User request
- Agent planner
- Tool call
- Token issued or reused
- Tool or API acts
- Result returned
There are four common ways the agent gets its token, and each leaks differently.
π§ Where each credential source leaks authority
Notice the pattern: in every case the token outlives or outsizes the task. The fix, which I cover in later sections, is to make authority match the single action being performed. For a wider view of how the pieces connect, see our AI agent threat modelling methodology.
Try this on paper before moving on. Pick one agent you know, perhaps a chatbot with access to a ticketing system. Write down which of the four sources it uses, how long that credential lives, and what it could do if someone else held it for an hour. Most students find at least one answer uncomfortable, and that discomfort is the starting point for the controls that follow.
Threat Model: OWASP ASI03 and NHI Risks for AI Agent Identity Security
I want to start the threat model with a map, because ai agent identity security is much easier once you know which failures you are looking for. The OWASP Top 10 for Agentic Applications 2026 was published by the OWASP GenAI Security Project on 9 December 2025. Entry ASI03 is Identity and Privilege Abuse. That is the one we care about here.
For the full list of risks, see the OWASP Top 10 for Agentic Applications explained. Below I stay on identity.
π Words I just used
OWASP gives a concrete example of caching going wrong. An agent caches a high-level credential, such as an SSH key, to apply a patch. If that session stays open, a non-admin user can later prompt the agent to reuse the borrowed power. The agent did nothing odd. The identity design let it happen.
The OWASP NHI Top 10 (2025) adds two entries that matter most for agents: NHI5, overprivileged non-human identities, and NHI7, long-lived secrets. It also reports enterprise machine-to-human identity ratios of roughly 45:1 to 100:1. Agents add to that pile.
Secrets sprawl shows how real this is. GitGuardian counted 28.65 million new hardcoded secrets on public GitHub in 2025, up 34% year over year. AI-service secrets reached 1.27 million, up 81%. Internal repositories are about six times more likely than public ones to contain hardcoded secrets. AI-assisted commits leak secrets at roughly twice the rate of human-written commits.
Each failure above has a deeper article. The pillar guide covers privilege abuse and secrets handling in more depth, and also shows how goal hijacking steers an agent into misusing the authority it already holds. For now, remember the pattern: identity flaws turn a small manipulation into a large impact.
π§ Quick check
Build Your Agent Identity Inventory
I always tell students the same thing: you cannot protect an identity you do not know exists. So the first practical control is a register of every agent and the authority it holds. Practitioners recommend covering each AI agent, its owner, associated service accounts, OAuth grants, API keys and connected business systems. Each agent also needs a defined purpose and a revocation path.
Let me show you a simple register. Make a file called agent-register.csv on your own machine. Every row is one agent, and every field answers a question you will ask during an incident.
Writes one sample row and prints the register as a readable table.
You should see two aligned rows: the header and the support-bot entry. If column is missing, install bsdmainutils or just open the file in a spreadsheet.
Now find the agents you forgot. Discovery sources matter because secrets turn up in odd places. GitGuardian found 24,008 unique secrets exposed in the MCP configuration files it studied, and about 28% of secret incidents come from collaboration and productivity tools, not code repositories. So look beyond Git.
βοΈ Where to look for agent identities
Here is a safe local scan of your own project folder. It only looks for common key-like patterns and prints file names, never the values.
Lists files in the current folder that may hold credentials. Output depends on your own files.
Credentials, OAuth 2.1 and MCP Authorization for Agents
Let me begin with the credential itself, because ai agent identity security is mostly decided by what the agent holds in its hand when it calls a tool. Good hygiene has three habits. Issue credentials scoped to one task. Keep them short-lived instead of using long-lived service account keys. Give each agent identity only the privilege it needs. Where you can, use certificate-based authentication rather than shared secrets or inherited tokens.
Now the protocol layer. MCP authorization is built on OAuth 2.1, and it mandates PKCE (a one-time proof that stops a stolen authorization code being reused) for all clients. Discovery uses RFC 9728 Protected Resource Metadata, so a client learns which authorization server to trust. RFC 8414 describes that server's metadata. RFC 8707 resource indicators bind a token to one specific MCP server.
- Agent client
- Protected resource metadata (RFC 9728)
- Authorization server (RFC 8414)
- Token bound to one server (RFC 8707)
- MCP server validates audience
- Tool-call authorization check
Two rules from the 2025-06-18 authorization spec matter most. An MCP server must validate that the token was issued specifically for it. It must also never pass that token through to upstream APIs, because that turns your server into a confused deputy. The spec also says authorization servers should issue short-lived access tokens, and public clients must rotate refresh tokens.
Finally, OAuth at the transport layer is not enough. You need a separate check at the tool-call layer that decides whether this agent may call this tool. Many deployments let one bearer token open every tool on a server. For wider background, see the MCP security guide.
π§ Quick check
I query the discovery documents of an MCP server running on my own machine, so I can see which authorization server it names and whether it requires audience binding.
Discovery JSON names the authorization server and PKCE S256 support, and an unauthenticated call returns 401. A 200 means authorization is not enforced.
Demo: Abusing an Over-Privileged Agent Identity
I will walk you through this one step by step, using the intentionally vulnerable confused-deputy lab. In it, FinanceBot runs as a system-level reconciliation tool and can move funds between any accounts. Alice is a low-privilege user chatting with it. The question is whose authority the bot uses when Alice asks. Everything here happens inside the SecurityElites lab, nowhere else.
π§ Confused-deputy walkthrough
A simple record of before and after, so your finding is reproducible.
The fix follows the delegation model: pass both the human's identity and the agent's own identity, so the agent never acts with more authority than the person who started the workflow. Add per-action scoping on top, so each call is judged on its own.
Run the demo yourself now that you have seen the shape of it.
βΈ Start by mapping what the bot can do versus what Alice can do.
βΈ Look for the moment the bot decides whose authority to use.
βΈ Capture the tool call with its parameters.
βΈ Then describe, in your own words, a check that would stop it.
What to notice: Whether the bot ever asks who the requesting user is How a friendly request still ends in a privileged action
Detecting Identity Abuse and Drift
Prevention fails sometimes, so I want you able to spot abuse after the fact. Detection for ai agent identity security starts with audit trails that record tool invocations, permissions granted, data accessed and outcomes. Without those four, you cannot tell a legitimate reconciliation run from a user steering the agent. Log the human user and the agent identity on every entry.
βοΈ Detection signals to build
Secret scanning deserves real attention. GitGuardian found 24,008 unique secrets exposed in the MCP configuration files it studied, and about 28% of secret incidents come from collaboration and productivity tools rather than code. It also reports AI-assisted commits leaking secrets at roughly twice the rate of human-written ones. So scan chat and ticket systems, not just git.
Drift is the slow version of abuse. An agent gains a scope for one project and keeps it forever. Compare each agent's live permissions against your inventory on a schedule, and flag anything the register does not explain.
For wider context on the risks your logs should catch, see the OWASP Top 10 for Agentic Applications breakdown, and use the AI agent threat modelling method to decide which agents deserve the tightest monitoring first.
π§ Quick check
Practise a Drift Check and a Revocation Drill
I want you to run a small drift check yourself, because reading about it is not the same as seeing a gap appear. We compare the names in your register with a list of agents you find running. Everything stays on your own machine, using plain text files.
First create a file called live-agents.txt with one agent name per line, as if you had pulled the list from your identity provider. Include support-bot and one extra name that is not in the register, such as report-bot. Then run the comparison.

