AI security · Day 14 of 100 · AI cybersecurity · 16 min

How Does an AI Agent Get Its Identity?

TLDR: AI agents use application identities, service accounts, and tokens issued through ordinary identity systems. Following an imaginary assistant called Pip, I explain how OAuth delegation works and why a receiving service still needs to authorize each requested action and resource.

I started with an embarrassing gap: I understood what an AI agent could do, but not how it was allowed to do it.

  • How was it authenticating?
  • Who had given it an identity?
  • Was it using my access or its own?
  • Had someone issued it an employee badge while I wasn't looking?

The answer was familiar: applications, service accounts and tokens. No secret AI login ceremony.

Let's follow an imaginary assistant called Pip. Its first job is to read a project folder and prepare a summary. A modest beginning. No need to give it the Death Star's admin account.

Who gives Pip an identity?

The people operating Pip choose its identity setup; an identity service maintains the record. An authorization server issues its access tokens, and the receiving service decides what those tokens permit. These are roles, sometimes supplied by the same platform.

Pip's chat name is not a security identity. Its application may use a dedicated identity, a shared service account, or a connection you authorized. A conversation ID tracks a run; it does not create an account.

The owner is accountable for Pip and its shutdown. A token is a temporary credential used to exercise its access.

The identity stays. Its passes expire.
P
IDENTITY RECORDPipOwner: project team
ACTIVE
Earlier
Token 1Expired
Now
Token 2Valid
Later
Token 3Issued if still authorized
Fig. 1. Illustrative managed identity: the authorization server can issue successive tokens against continuing permission. An identity record is not itself an access token.

Pip can keep an identity while its tokens expire. But no universal identity follows every agent across companies. This is a design choice, not an AI birth certificate.

AWS AgentCore and Microsoft Entra offer examples, not a universal model.

Is OAuth authentication or authorization?

OAuth authorizes access. Authentication establishes who is signing in or which application is calling. A flow can involve both.

The client requesting access is Pip’s application or connector, not the human or the model itself.

  • An ID token, in OpenID Connect, tells the client about the user's authentication: who signed in.
  • An access token is presented to an API to exercise authorized access: what this request may access, subject to the API's checks.

“You signed in” and “this app may read documents” are different claims. OpenID Connect adds the identity layer; its ID token cannot replace an API access token.

Does somebody have to log in to give Pip access?

Sometimes. OAuth supports both access delegated by a user and application access without a user signing in. The difference is where the permission comes from.

Route one: Pip acts on your behalf

You connect the document service, sign in if needed, and approve access under its consent and policy rules.

The app exchanges the returned code for an access token. Production flows also need safeguards such as PKCE, which binds the code exchange to the client that started it. A refresh token may obtain later access tokens without another login. You do not type your password for every document Pip reads.

Route two: Pip acts with the application's own permission

For an application that can securely authenticate itself, an administrator grants application permissions. The app requests a token using the client credentials grant, without a human login or impersonated user.

The app authenticates. The token comes back.
Administrator’s policy Read project documents
Pip’s
application
1. Client authentication + request →
← 2. Access token
Authorization
server
No user login in this exchange
Fig. 3. Client credentials grant: the server issues the token back to the application, within its configured permissions. The token is not a third participant.

These OAuth flows support different permission sources, not different safety guarantees. Pip may need only the Apollo folder while its application account can read every company folder. An attacker who redirects Pip could retrieve payroll too. A dedicated identity does not itself restrict permissions.

The API call is machine to machine; its permission can still come from a user. Unattended work may continue under an existing user-delegated grant.

When Pip requests a document, the API must decide whether to trust and allow it. That decision point is a security boundary, not necessarily a separate physical server.

A gateway or API middleware may validate the token; the application must also enforce access to that document. Database policies can add enforcement. Together, the checks must stop an Apollo-only request from reading payroll.

The API checks the request at its boundary.
1 · PIP’S API REQUESTRead project folderAttached: access token
→2 · API checksToken valid?Read allowed?
3 · PERMITTED RESOURCE
Project folder✓ Allowed
Other resourcesNot granted by this request
Fig. 4. Illustrative restricted grant: the token travels with the request. The API validates it and applies resource policy; a valid token does not open every folder.

Keep credentials outside the model’s prompt: whoever possesses a bearer token can use its permitted access. Treating one as conversation material is a poor career move.

What does this look like in ChatGPT, Claude or a local agent?

Your login to an assistant and its access to another service are separate relationships. Signing into a chat product does not, by itself, give it your document account.

Where Pip runs Where connected access comes from
A ChatGPT integration For an OAuth-protected MCP integration, ChatGPT acts as the client and runs the service's authorization flow. The service checks the resulting token.
A Claude connector Typically, you sign into the connected application and grant access through OAuth. Some custom connectors instead use configured fixed credentials or require no sign-in.
An agent on your computer A local tool can run with the operating-system permissions and credentials made available to its process. A remote connection can still use OAuth.

Connection details vary: see OpenAI’s authentication guide, Claude’s connector guide, and Claude Code’s MCP examples.

Local stdio means two processes exchange messages through standard input/output. It is a transport, not a login. A local tool may use credentials from its environment and the process’s operating-system permissions; the remote OAuth flow does not automatically apply. The MCP specification distinguishes these arrangements.

Pip uses an MCP server. Where does the next token come from?

Pip asks a connector for an Apollo document; the connector calls the document service. Downstream means the next service called to fulfil a request: here, the document service.

The document API serves files and enforces access. The document authorization server checks grants and issues tokens for that API. One provider may operate both roles.

The document authorization server issues Token B; the connector cannot invent permission because Pip asked nicely.

MCP lets applications call tools. Pip’s application contains the MCP client; the connector providing the tool is the MCP server.

Pip presents Token A to the protected remote connector. To call the separately protected document API, that connector needs Token B.

Example: you previously connected your document account. The connector was registered, you approved access, and the document authorization server issued a refresh token. Registration identifies the client; it does not grant document access.

For a fresh B, the connector presents that refresh token and applicable client authentication. The server checks the grant and client binding before issuing B. This refresh-token flow does not exchange A for B:

An approved connection comes before Token B.

The connector presents its document-service refresh token. Token A stays at the connector.

Earlier: you approved the document connectionRegistered connector + your grant → document-service refresh token held by the connector
  1. Pip application → MCP connectorTool request + A. The connector validates A and authorizes this caller’s document request.
  2. MCP connector → Document authorization serverRequest B using the stored refresh token + applicable client authentication.
  3. Document authorization server → MCP connectorValidate the refresh grant and client binding; issue B for the document API.
  4. MCP connector → Document APIDocument request + B. The API validates B and enforces access to this document.
  5. Document API → MCP connector → Pip applicationReturn the authorized document, then the tool result.
Fig. 5. Existing user-delegated connection, with a fresh B needed for this request. A permits the call to the connector; B permits its call to the document API, subject to resource checks. The refresh grant supplies B, not Token A. A still-valid B could be reused without refreshing on every call.

Alternatively, the connector can use administrator-granted application access. Token exchange presents one credential to an authorization server to request another under policy. RFC 8693 covers that separately configured option; it is not automatic in MCP or used above.

Without an approved arrangement, the connector must fail or request a connection. A alone is insufficient.

One connector checks A, then uses B.
Pip’s application
1 Tool request + Token A ↓
THE SAME MCP SERVER
2Check AMay Pip use this tool?
3Use BSeparately authorized document access
4 API request + Token B ↓
Document APIChecks B and document permissions
Fig. 6. Read top to bottom. A terminates at the MCP server. That same server makes a new request using B, obtained from the document authorization server; it does not turn A into B by itself.

Why not forward A? A cinema ticket is not a train ticket merely because both have a barcode. A was issued for a different recipient. MCP security guidance prohibits blindly passing it through.

Suppose a shared connector can read Apollo and payroll, but you may read only Apollo. If it accepts your payroll request merely because you may call the tool, it lends you authority you lack. This is a confused deputy: a trusted service misusing its power for an unauthorized caller. It must check your access to the file; accepting a broadly privileged B does not establish your own right to the file.

How does the whole authorization flow fit together?

Two connections enable one request: Pip can call the connector, and the connector can call the document API. Here is the complete route.

This example uses delegated access on both connections. Setup and consent need not repeat for every request; renewal still depends on a usable grant.

The whole route: permission, request, result.
1
Owner registers the apps and sets their limitsPip’s application · MCP connector · allowed resources
2You authorize MCP access
MCP authorization server
↓ issues A
Pip’s application receives A
3You connect your document account
Document authorization server
↓ issues B
MCP connector receives B
NOW PIP RUNS THE TASK
Pip’s appChooses tool call
4Request + A→
MCP serverChecks A + action
5Request + B→
Document APIChecks B + resource
6
← Authorized data returns through MCP to PipPip prepares the summary for you.
Fig. 7. One remote-MCP design with two user-delegated connections. Follow 1–6: setup, two grants, two authenticated requests, then the result. Steps 2 and 3 use the OAuth code exchange shown earlier. Existing grants and valid tokens can be reused; app-only setups use administrator-authorized application access instead. A and B need not share an issuer.

The model chooses the call; software handles credentials and enforcement. Passing those checks does not prove it chose the right mission.

How does legitimate authority get abused?

Attackers can steal credentials or persuade their legitimate holder to misuse them. In the second case, every token signature can remain valid.

Pip's badge works. The problem is whose instructions Pip follows after entering the building.

1. Send credentials to the wrong place

An OAuth client can be misled about where to send credentials. A September 2026 MCP Python SDK advisory describes credential exposure involving malicious authorization metadata and missing issuer or credential binding.

The client is tricked into sending secrets away.
1
Malicious server supplies metadataIts metadata directs the client to an attacker-controlled token endpoint.
2
OAuth client trusts that destinationIssuer and credential-binding protections are missing.
Expected authorization server
Not where the credentials go
3Client sends credentials → attacker
Fig. 8. Simplified advisory scenario, in order: malicious metadata changes the destination, inadequate binding lets the client trust it, and credentials go to the attacker.

The fix requires the SDK patch and appropriate issuer and client-registration configuration, not trust in whatever endpoint arrives.

2. Accept a real token meant for somewhere else

A token can be genuine and still be wrong for the service receiving it. An October 2026 Python SDK advisory describes missing audience enforcement. A signature check alone does not establish the intended recipient. Upgrading alone is insufficient: deployments must enable audience enforcement or enforce it in their verifier.

Valid signature. Wrong recipient.
PRESENTED TOKENFor service AGenuine signature
SERVICE B’S VERIFIER
Signature valid✓
Intended for B?NOT CHECKED
Access wrongly accepted
Fig. 9. The flaw is the missing recipient check. This is a depiction of the vulnerable case, not a recommended validation sequence.

3. Persuade an authorized agent to leak private data

Here the attacker changes the agent's instructions rather than its credentials. Invariant's GitHub MCP demonstration placed malicious instructions in a public issue. With the demonstrated access and approval conditions, the agent retrieved private repository information and exposed it in a public pull request. This was a researcher demonstration, not evidence of a GitHub platform breach.

Instructions enter publicly. Private data leaves.
1Agent reads a poisoned public issue↓ attacker instructions influence its next actions
PRIVATE REPOSITORY2Agent reads private dataExisting valid access
then
→
PUBLIC PULL REQUEST3Agent publishes the data
Fig. 10. Invariant’s demonstrated sequence: read the malicious issue, retrieve private repository data, expose it in a public pull request. The issue supplies instructions; the private repository supplies the leaked information.

In my MCP response-poisoning lab, the agent spotted the injection. I then tested routing directly: the vulnerable local test bridge accepted an unauthorized recipient. Tool enforcement must hold even when model judgment does not.

4. Turn retrieved content into an outbound leak

The reported EchoLeak chain used malicious email content encountered by Microsoft 365 Copilot to drive an outbound data leak. The assistant's legitimate access became part of the attack path. The researchers' account describes the chain and remediation; this is a historical case, not a claim that the same flaw remains exploitable today.

The leak rides an outbound request.
✉
1 · ATTACKER EMAILInstructions hidden in retrieved content
2 · Retrieved into ↓
Assistant’s working context
Legitimate private context + Injected instructions
3 · Outbound request carries private data ↓
attacker.example / …Private data
Attacker-controlled destination
Fig. 11. Conceptual view of the reported EchoLeak chain, not a literal payload. The reported chain used browser image fetching through an allowed proxy. The injected email redirects the use of available context into an outbound leak; this does not require a stolen token.

In both cases, content to read becomes instructions to obey. A valid token cannot tell the difference.

What can we do about it now?

Give Pip less standing power, and enforce the important decisions outside the model.

  • Give each connection an accountable owner and a way to revoke access.
  • Limit resources, actions and token lifetime; keep credentials out of prompts.
  • Validate the issuer, intended recipient and permissions at each service.
  • Enforce allowed files, recipients and destinations in the tool or gateway.
  • Require specific approval for consequential actions, bound to what will actually execute.
  • Record the user, agent, tool and outcome so the action can be traced.

These reflect the OWASP AI Agent Security guidance. “Read the project folder” should not quietly become “publish its contents.” Pip may be enthusiastic; the permission system should be boring.

Do we need an alternative to OAuth?

OAuth grants access; it does not decide whether a tool call matches your task. Changing token formats alone will not solve that mismatch.

Two complementary directions look especially useful:

  • Workload identity: only the approved Pip deployment should receive Pip’s identity. Checking evidence about the running process and environment against policy is attestation. Establishing which workload qualifies is the foundation; short-lived credentials are one benefit. SPIRE attestation documentation explains this approach, which can complement OAuth.
  • Task-specific authority: restrict permission to “read this folder” or “buy this approved cart.” Google’s AP2 payment mandates illustrate the direction, not a universal solution.

For Pip, the useful improvement is a pass tied to the job, with an enforceable boundary. A shinier badge is optional.

Where is agent identity heading?

My bet: agents become managed participants in delegated work, with distinct identities, limited permissions and accountable owners. Keeping those limits intact across handoffs is the challenge.

NIST’s identity discussion connects this to familiar IAM problems: shared credentials blur accountability; long-lived secrets and excessive access magnify mistakes. Existing foundations help, but adopting a protocol does not make an agent safe.

Why does Pip need an identity lifecycle?

Permission must change with the job, owner or deployment. Pip’s project can end while its connector still holds a usable grant. Removing the chat shortcut does not end that access.

The job ends. Does the access end too?

Keep an accountable owner through permission reviews and verified shutdown.

  1. Create → owner, purpose, identityRecord who is responsible for Pip and what it is here to do.
  2. Grant → approved resources and actionsAllow the Apollo folder, not every company folder.
  3. Operate → credentials and action recordsIssue credentials under policy; log actors, actions and outcomes.
  4. Review → job, owner or tools changeReassess permissions; return to operation only with approved limits.
  5. Retire → stop work and revoke accessStop jobs, disable new credentials and revoke relevant grants.
  6. Verify → test the services Pip could reachConfirm new tokens cannot be obtained and document access is denied. Account for already-issued tokens.
Fig. 12. Illustrative lifecycle. Review repeats while Pip operates; retirement follows when the job ends. Removing a chat shortcut is not proof that its connected access has stopped.

A continuing grant can renew tokens, and disabling Pip may not immediately invalidate existing ones. Test the services it could reach. Otherwise we have invented an employee who leaves but keeps renewing the door pass.

What happens when agents call other agents?

Each handoff needs a verifiable identity and limited authority. A more powerful agent must not lend its full privileges to every caller.

An identifiable actor is a security identity the receiving system can verify and authorize, not an agent name in a prompt.

You approve a laptop task and budget. Pip delegates quote comparison, supplier review and the approved purchase to three agents with separate identities. The purchasing agent’s wider company access must not expand this order’s authority:

One job. Separate identities. Smaller permissions.

Every receiving service checks the actor and its authority for this task.

You approve the laptop task and budget↓ Pip coordinates under its own verified identity: agent:pip
↓ Pip delegatesSourcing agentagent:sourcingCompare quotes only.
No order submission.
↓ Pip delegatesReview agentagent:reviewCheck supplier only.
No spending authority.
↓ Pip delegatesPurchasing agentagent:purchasingSubmit approved order only.
After quote and supplier review.
Purchasing agent → Purchase serviceVerify identity + delegated authority. Enforce approved supplier, items, total budget and expiry.
Within limits → executeOutside limits → reject / new decision
Each handoff and service decision → Audit recordsVerified actor · parent task · authority used · action · outcomeA shared task ID connects records. It does not grant permission.
Fig. 13. Illustrative control design, not a claim about universal platform support. Identity labels stand for separately verified identities. Pip delegates different work to each specialist; purchasing waits for the required results and approval. Services enforce authority and record decisions as handoffs multiply.

A changed supplier, amount or delivery destination needs a new decision under policy. A subagent should not gain permission because another agent wrote “urgent” in a prompt.

The audit must identify who requested, delegated and executed the action, under what authority. Shared task IDs connect records; shared credentials obscure actors. Token exchange can support delegation, but does not supply every business constraint or cross-service revocation rule.

Approve the transaction, not merely access to the tool. The purchase service must enforce supplier, items, budget and expiry.

Permission for one small purchase must not become permission for a thousand. AWS’s work across agent actions illustrates why controls extend beyond individual calls.

Routine work can run inside approved limits; exceptions need specific decisions. Approving every harmless lookup would turn oversight into a clicking competition.

Across organizations, each must decide which identities and delegations it trusts. More handoffs mean more accountability to preserve, not fewer people responsible.

Takeaways

  • Pip gets access through ordinary software identity and credential systems.
  • OAuth can support user-delegated access or app-only access; neither guarantees safe behavior.
  • Each service boundary needs appropriate authority. In this OAuth example, the connector obtains its document-API token from an authorization server under an approved grant.
  • A valid credential can survive the entire attack. The tools must still enforce the task's limits.

I started by asking who gave Pip a badge. The more useful question turned out to be who can limit what Pip does with it, and take it away when the job is done.

Filed under AI security, identity, OAuth, MCP, authorization. If any of this is wrong, or you have hit the same thing, tell me.

Published 20 October 2026. Updated .

Ryan Sacatani

Simply curious about the world, constantly building and breaking things for fun.

sacataniryan1@gmail.com ↗

BrowseBrowse topics

Browse