AI agents accumulate credentials faster than any other identity type, and almost none of them are tied to the agent's own lifecycle: keys outlive the pilot, OAuth grants outlive the user's interest and tokens outlive the task. An agent may hold its own workload credential, delegated user tokens for several SaaS tools, API keys for model providers and MCP servers, and certificates for service-to-service calls, each with a different issuer, lifetime and revocation path. This guide sets out the lifecycle for each type of agent credential, the events specific to agents that should trigger rotation or revocation (a model swap, a new tool, a sub-agent, a sponsor leaving), the lifetimes major platforms actually offer, and how to measure that credentials end when the work does. Where secrets are stored and released is covered in the Credential Vaulting for AI Agents Guide; this page covers what happens to them over time. It is for identity, platform and security engineers running agents in production.
Key takeaways
- Lifetime should follow the unit of work. Agent identity credentials last hours, task tokens last minutes, delegated user grants last as long as the user's consent and no longer, and static keys exist only where a provider offers nothing else.
- Agents have their own lifecycle triggers. Beyond joiner, mover and leaver, rotate or re-scope on new tools, changed prompts or models, new sub-agents, environment promotion and the departure of the human sponsor.
- Revocation must reach every issuer. Disabling the agent in one directory does not revoke the SaaS refresh tokens, MCP server keys or model API keys it holds. Keep an inventory that maps each agent to every credential and issuer.
- Prefer credentials that expire by design. Federated and attested workload credentials, one-hour app installation tokens and short cloud sessions remove most rotation work; long-lived secrets are the exception that needs a rotation runbook.
- Retirement is the most skipped stage. Pilots end, agents are replaced and AI apps are forgotten while their grants remain valid, which is how a forgotten AI app's OAuth token became the way into Vercel.
The credentials an agent holds
| Credential type | Typical issuer | Purpose | Native lifetime and rotation |
|---|---|---|---|
| Agent workload identity (federated credential, certificate, WIMSE WIT, SPIFFE SVID) | Identity platform or workload identity system | Prove which agent is calling | Short and automatically renewed when federated or attested; WIMSE drafts recommend WITs of hours with per-request proofs of minutes |
| Agent blueprint or application credential (client secret, certificate) | Directory (for example Microsoft Entra) | Lets the platform mint tokens for agent instances | Secrets and certificates have set expiry and need rotation; federated credentials avoid stored secrets |
| Delegated user access and refresh tokens | OAuth authorisation servers of SaaS and MCP servers | Act for a user at a specific resource | Access tokens minutes to an hour; refresh tokens vary widely and may not expire unless the issuer sets policy |
| App-only access tokens (client credentials, app installation tokens) | OAuth servers, GitHub Apps and similar | Act as the agent itself | GitHub installation tokens expire after one hour and can be narrowed to repositories and permissions |
| Cloud session credentials | AWS STS, cloud workload identity federation | Call cloud APIs | AWS AssumeRole sessions 15 minutes to 12 hours (default one hour), one hour maximum when role chaining |
| Static API keys | Model providers, SaaS tools, internal services | Simple bearer access | Often never expire; rotation is manual or scripted |
| Signing keys (request signing, Web Bot Auth, artefact signing) | The agent operator | Sign requests or outputs | Operator-defined; rotate by overlap |
Platform designs differ in where the credential lives. In Microsoft Entra Agent ID, agent identities have no credentials of their own: the agent identity blueprint holds federated identity credentials, certificates or client secrets and acquires tokens on the agents' behalf, so the blueprint credential is the one to protect and rotate. In Amazon Bedrock AgentCore Identity, a token vault stores OAuth tokens and API keys so that only the agent and user combination that obtained them can retrieve them, and resource credential providers handle obtaining and refreshing them. See Cloud Agent Identity Services Compared (Entra, AgentCore, Google).
The lifecycle stages
- Request and approve: a named sponsor requests the agent, its purpose, the tools it will call and the data it will touch. Entra Agent ID records a sponsor as the human or group accountable for the agent; whatever the platform, record one.
- Issue: issue the agent's own identity credential through federation or attestation where possible, never by copying a human's key. Issue delegated tokens only through an interactive consent or an approved token exchange.
- Scope: narrow each credential to one resource (audience), the fewest scopes and one environment. The MCP authorisation specification requires clients to send the RFC 8707
resourceparameter and servers to validate that tokens were issued for them; RFC 9700 says access tokens should be audience-restricted. - Bind: sender-constrain where the issuer supports it (mTLS, DPoP, WIMSE proof tokens) so a copied token is useless. RFC 9700 requires refresh tokens for public clients to be either sender-constrained or rotated.
- Use and observe: log every issuance and use with the agent identifier, the task and, for delegated tokens, the user.
- Renew and rotate: renewal is automatic for short-lived credentials; rotation is a planned change of a longer-lived secret or key (see the rotation section).
- Re-scope: when the agent's tools, data or autonomy change, reissue credentials with the new scope rather than adding permissions to the old ones.
- Suspend and revoke: on incident, misuse or the user withdrawing consent, revoke at every issuer, not just in the agent registry.
- Retire: on decommissioning, revoke all credentials, delete stored tokens, remove the identity, and keep audit records.
Agent-specific lifecycle triggers
| Event | Why it matters | Credential action |
|---|---|---|
| New tool, MCP server or API added | New resource, new attack surface | Issue a new, audience-bound credential for that tool; do not widen an existing one |
| Model, system prompt or agent code changed materially | Behaviour may change; earlier risk assessment may no longer hold | Re-approve scopes; rotate long-lived secrets if the old build could have exposed them |
| Agent spawns sub-agents | Authority can propagate further than intended | Give sub-agents their own narrower, shorter credentials through token exchange; never hand down the parent's |
| Promotion from test to production | Test credentials often over-scoped and widely shared | New production credentials; destroy test ones |
| Delegating user leaves or withdraws consent | The agent keeps acting for someone with no current right | Revoke that user's refresh tokens and stored grants for the agent |
| Sponsor leaves or changes role | No one accountable; reviews stop | Reassign sponsor within a set period or suspend the agent |
| Credential appears in logs, prompts, traces or a repository | Treat as compromised | Revoke and reissue immediately. See the Leaked Credential Response Playbook. |
| No activity for a set period | Likely orphaned | Suspend credentials, notify sponsor, retire if unclaimed |
| Third-party agent vendor breached | Tokens you granted them may be stolen | Revoke grants to that vendor's apps and reissue after review |
Setting lifetimes
| Credential | Recommended lifetime | Rationale |
|---|---|---|
| Per-request proof (WPT, HTTP signature, DPoP proof) | Seconds to minutes | WIMSE drafts specify minutes or less for proofs |
| Task access token | Task length plus margin, typically 5 to 60 minutes | Limits replay window; renewable within the task |
| Agent workload identity credential | Hours, auto-renewed | Matches WIMSE guidance for WITs; cannot usually be revoked on demand, so expiry does the work |
| Cloud session | 15 to 60 minutes for interactive agents; longer only for batch jobs that need it | AWS allows 15 minutes to 12 hours; set the role's maximum session duration to what agents need |
| Delegated refresh token | Bounded by policy (for example, days of inactivity and an absolute maximum), rotated on use | Refresh tokens are the long tail of agent access. See the OAuth Refresh Token Rotation and Expiry Guide. |
| Blueprint or application secret or certificate | Replace secrets with federated credentials; certificates 90 days or less with automated renewal | The root from which agent tokens are minted |
| Static API key | As short as the provider allows; rotate at least every 90 days and on every trigger above | OWASP NHI Top 10 lists long-lived secrets (NHI7) as a top risk |
Small versus large teams: a small team should first remove static keys where federation exists, set refresh token policy at the identity provider and keep a spreadsheet inventory with owners. A large organisation needs automated discovery of agent credentials across clouds, SaaS and code, a registry linking agent identifier to every credential and issuer, and rotation run by pipelines rather than people.
Rotation without outages
- Overlap, then cut over: create the new secret or key, deploy it to the agent runtime, confirm traffic uses it, then revoke the old one. Two valid credentials should coexist only for a defined window.
- Rotate the root, not just the leaves: rotating agent access tokens achieves little if the blueprint secret or signing key behind them never changes.
- Refresh token rotation: where the issuer rotates refresh tokens on use, detect reuse of an old one as a theft signal and revoke the whole grant.
- Scripted runbooks per provider: each model provider and SaaS tool has its own key API. Script rotation and record the last rotation date per key. See the Secrets Rotation Runbook Template.
- Do not rotate by redeploying images: a key baked into a container image or agent configuration file survives in every old artefact (T1552.001 Credentials In Files). Inject at runtime instead.
Revocation and retirement
Revocation is where agent credential programmes most often fall short, because agent credentials are spread across many issuers. Build a revocation path for each issuer and test it.
| Issuer | How to revoke | What survives revocation if you stop there |
|---|---|---|
| Agent identity platform | Disable the agent identity or, in Entra, act on all agents of a blueprint (disable, revoke a permission grant) | Third-party tokens already issued to the agent |
| SaaS and MCP authorisation servers | Revoke the user's grant or the client's tokens (RFC 7009 revocation endpoint where offered); remove the app connection | Access tokens until expiry unless introspected |
| Token vault | Delete stored tokens for the agent and user pairs | Tokens still valid at the issuer if not revoked there too |
| Cloud provider | Remove trust policy or federation; revoke active sessions | Existing STS sessions until expiry unless explicitly revoked |
| Model and SaaS API keys | Delete the key in the provider console or API | Nothing, if deleted, but copies in logs and traces must still be purged |
The Vercel Context.ai OAuth breach shows the cost of skipping retirement. An employee had connected an AI office app to a corporate Google account with broad access; the grant was never reviewed or given an expiry, so when the AI vendor was breached the stolen token still worked and gave the attacker the account without a password or MFA. Periodic review of AI app grants, and revocation on disuse, would have closed that path. See the Consent Phishing and Illicit OAuth Grants Guide.
How to implement
- Inventory: for every agent, list each credential, issuer, scope, lifetime, storage location, last rotation and sponsor. Include AI apps users connected themselves.
- Classify: mark each as expiring by design, rotatable secret or static key, and set a target lifetime from the table above.
- Remove the worst first: replace static keys and blueprint secrets with federation where the platform supports it; narrow over-scoped tokens.
- Wire triggers: connect agent registry events (tool added, model changed, sponsor left, inactive) to credential actions in your automation.
- Build revocation per issuer: script it, then run a tabletop and a live test that revokes a test agent end to end and confirms no credential still works.
- Pilot: apply the new lifetimes to one agent class first, watch for task failures caused by expiry, and adjust margins rather than reverting to long lifetimes.
- Roll back safely: if shorter lifetimes break a job, extend that job's lifetime explicitly with an owner and end date; never return a whole class to non-expiring credentials.
- Review quarterly: sponsors attest to each agent's credentials and scopes. See the Identity Governance for AI Agents Guide.
Detection and measurement
- Log: issuance, renewal, rotation and revocation events with the agent identifier; token use per resource; AWS
SourceIdentityor equivalent so chained sessions stay attributable. - Alert: use of a credential after its agent was retired; refresh token reuse; new credentials added to an agent's application outside the pipeline (T1098.001 Additional Cloud Credentials); agent tokens used from unexpected networks (T1550.001 Application Access Token, T1528 Steal Application Access Token).
| Metric | Target |
|---|---|
| Agents with a complete credential inventory and named sponsor | 100% |
| Share of agent credentials that expire by design | Rising; static keys only where no alternative exists |
| Median lifetime of agent access tokens | Under one hour |
| Static keys older than 90 days | Zero |
| Time from retirement decision to last credential revoked | Same day |
| Credentials still valid for retired or inactive agents | Zero |
Framework mapping
| Framework | Reference | Relevance |
|---|---|---|
| OWASP Non-Human Identities Top 10 (2025) | NHI1 Improper Offboarding, NHI2 Secret Leakage, NHI5 Overprivileged NHI, NHI7 Long-Lived Secrets, NHI9 NHI Reuse | The risks each lifecycle stage addresses |
| NIST SP 800-53 Rev. 5 | IA-4, IA-5, IA-5(13), AC-2(3), SC-12, SC-17, AU-6 | Identifiers, authenticator lifecycle, cached authenticator expiry, disabling accounts, key and certificate management, review |
| NIST CSF 2.0 | PR.AA-01, PR.AA-05, DE.CM-03 | Credential management, least privilege, monitoring of use |
| ISO/IEC 27001:2022 Annex A | A.5.16, A.5.17, A.5.18 | Identity management, authentication information, access rights |
| MITRE ATT&CK v20 | T1528, T1550.001, T1552.001, T1098.001, T1078.004 | Theft, reuse, exposure, persistence and cloud account misuse |
Common failure patterns
- Pilot keys in production: a broad key created for a proof of concept quietly becomes the production credential.
- Human credentials lent to agents: a developer's personal access token powers the agent, so access ends when they leave or, worse, does not (NHI10 Human Use of NHI).
- One credential, many agents: several agents share a key, so rotation breaks all of them and logs cannot tell them apart (NHI9 NHI Reuse).
- Directory-only offboarding: the agent is disabled in the identity platform while its SaaS refresh tokens and model API keys keep working.
- Forgotten AI app grants: users connect AI tools to corporate accounts with broad scopes and no expiry, as in the Vercel case.
- Sub-agents inheriting the parent's token: authority spreads with no record of who passed it on. See Delegation Chains and Attenuated Authority for AI Agents.
Practitioner checklist
- Map every agent to every credential, issuer, scope, lifetime and sponsor.
- Use federated or attested identity credentials for the agent itself; remove stored blueprint secrets where possible.
- Bind tokens to one resource and sender-constrain them where issuers support it.
- Set lifetimes per credential type and enforce refresh token policy at each issuer.
- Trigger re-scoping or rotation on new tools, model or prompt changes, sub-agents and promotion.
- Revoke delegated grants when users leave or withdraw consent, and reassign or suspend on sponsor departure.
- Script revocation for every issuer and test it end to end on a test agent.
- Review AI app grants users created and revoke unused ones.
- Alert on any credential use by a retired or inactive agent.
Standards and references
- OWASP: Non-Human Identities Top 10 (2025)
- IETF: RFC 9700 OAuth 2.0 Security Best Current Practice
- Model Context Protocol: Authorization specification
- IETF: WIMSE Workload Credentials (draft-ietf-wimse-workload-creds)
- Microsoft Learn: Agent identities in Microsoft Entra Agent ID
- AWS: AgentCore Identity terminology
- AWS: STS AssumeRole API reference
- GitHub Docs: Generating an installation access token for a GitHub App
Related NHI Mgmt Group resources: Credential Vaulting for AI Agents Guide · OWASP NHI Top 10 NHI7 Long-Lived Secrets Guide · Dynamic Secrets and Ephemeral Credentials Guide · WIMSE for AI Agents Guide