Most identity programs were built around people: joiners, movers, leavers, access reviews, MFA. Meanwhile, the identities that actually call your APIs all day (service accounts, API keys, OAuth client apps, CI/CD pipelines, certificates, bots, and now AI agents) have quietly become the larger and less governed population.
They don't use MFA. They rarely have an owner. Their credentials are often long-lived secrets copied into config files, pipelines and wikis. And unlike a person, an AI agent can chain hundreds of API calls in seconds on behalf of whoever prompted it.
Analysts call this discipline non-human identity (NHI) management or machine identity management; with agentic AI it has become one of the most urgent gaps in enterprise identity security. This article (updated November 2026) is a practical blueprint for fixing that. Every recommendation maps to a published standard or specification, with no vendor marketing, so you can defend each decision to an auditor, an architect, or a CISO.
1. The problem: the OWASP Non-Human Identities Top 10 explained
A non-human identity (NHI) is any identity used by software rather than a person to authenticate: service principals, managed identities, IAM roles, API keys, OAuth clients, X.509 workload certificates, SSH keys, bot accounts and AI agents. The OWASP Non-Human Identities Top 10 (its 2025 edition is still the current version as of November 2026) catalogues the failure modes seen repeatedly in real environments:
- NHI1: Improper Offboarding: identities outlive the project, vendor or employee that created them.
- NHI2: Secret Leakage: keys and tokens end up in source code, logs, tickets and chat.
- NHI3: Vulnerable Third-Party NHI: integrations and OAuth apps you granted broad access to, then forgot.
- NHI4: Insecure Authentication: deprecated or weak flows (shared secrets, implicit grant, password-based service logins).
- NHI5: Overprivileged NHI: "just give it Contributor", the most common shortcut in every cloud.
- NHI6: Insecure Cloud Deployment Configurations: CI/CD and cloud workloads using static credentials or over-trusting federation.
- NHI7: Long-Lived Secrets: credentials that never expire and are never rotated.
- NHI8: Environment Isolation: the same identity used across dev, test and production.
- NHI9: NHI Reuse: one identity shared by many applications, destroying accountability.
- NHI10: Human Use of NHI: people logging in as service accounts to bypass MFA and approvals.
AI agents amplify every item on this list. An agent that holds a broad, long-lived token is effectively an unsupervised super-user that takes instructions in natural language, including from content it reads (prompt injection). The fix is not a new product category; it is applying established identity standards to software with the same rigor we apply to people.
2. What changed in 2026
Updated November 2026. This year moved AI-agent identity from conference talk to shipped standards, products and published guidance. The developments below shape the recommendations in this article.
- MCP authorization was overhauled (specification 2026-07-28). Client ID Metadata Documents are now the default way MCP clients identify themselves, and Dynamic Client Registration is formally deprecated. Clients must validate the authorization server's issuer (RFC 9207), client credentials are bound to the authorization server that issued them, and an Enterprise-Managed Authorization extension lets organisations control which MCP servers agents may use. New
Mcp-Method/Mcp-Nameheaders let API gateways enforce policy per tool call. - The first MCP SDK OAuth vulnerability with a CVE. In October 2026 GitHub published an advisory for the MCP TypeScript SDK (CVE-2026-104850): an OAuth client could send credentials to an authorization server chosen by a malicious MCP server. It is exactly the class of attack the new issuer-validation rules address, patch SDKs and treat MCP servers as untrusted until approved.
- OWASP published the Top 10 for Agentic Applications for 2026: a peer-reviewed companion to the Non-Human Identities Top 10 that covers risks specific to autonomous agents, including identity and privilege abuse.
- NIST began standardising agent identity. The NCCoE concept paper Accelerating the Adoption of Software and AI Agent Identity and Authorization (February 2026) frames how agents should be identified, authorised, delegated and logged using existing standards such as OAuth.
- NIST IR 8587 was finalised (September 2026). Protecting Tokens and Assertions from Forgery, Theft, and Misuse, written with CISA in response to token-forgery incidents, sets recommendations for signing-key protection, token validation and short-lived tokens: the controls behind threats T-1 and T-6 below.
- Transaction Tokens neared standardisation. The IETF draft (version 11, July 2026) defines short-lived tokens that carry the original caller's identity and context through a chain of internal services, a strong fit for multi-agent and microservice call chains. It is not yet an RFC.
- Agent identity became a product category. Microsoft Entra Agent ID is generally available, with agent identity blueprints, human sponsors and Conditional Access for agents; Okta launched Agent SSO with Cross App Access (August 24, 2026); AWS offers Amazon Bedrock AgentCore Identity for agent credentials.
- Market consolidation. Palo Alto Networks completed its acquisition of CyberArk in February 2026; the identity security platform is now branded Idira.
What it means in practice: agents should have their own registered identities with human sponsors; MCP clients and servers should be upgraded to the 2026 authorization model; and token-forgery defences (NIST IR 8587) belong in every identity architecture review.
3. The standards this blueprint is built on
- NIST SP 800-207: Zero Trust Architecture: no implicit trust based on physical or network location (§2); all communication is secured regardless of network location and access is granted per session (§2.1, tenets 2 to 3).
- NIST SP 800-63-4: Digital Identity Guidelines (finalized July 2025, released August 1, 2025): authenticator assurance levels and phishing-resistant authentication for the humans who own and delegate to agents.
- RFC 9700: Best Current Practice for OAuth 2.0 Security (BCP 240, January 2025): the IETF's current hardening guidance: servers SHOULD sender-constrain access tokens, tokens SHOULD be audience-restricted, and clients SHOULD NOT use the implicit grant.
- RFC 8693: OAuth 2.0 Token Exchange: how one party obtains a token to act on behalf of another. It defines the
act(actor) claim, which records who is really making the call, andmay_act, which lets a token name who is allowed to act for its subject. - RFC 8707: Resource Indicators: tokens minted for one specific API (audience), so a stolen token is useless elsewhere.
- RFC 9449: DPoP and RFC 8705: mutual-TLS bound tokens: sender-constrained tokens that only work when presented by the holder of a private key.
- RFC 7523: JWT client assertions: used by
private_key_jwtclient authentication (defined in OpenID Connect Core 1.0 §9): clients authenticate with a signed assertion instead of a shared secret. - RFC 9728: OAuth 2.0 Protected Resource Metadata (April 2025): APIs advertise which authorization server and scopes they accept, required for MCP servers by the Model Context Protocol authorization specification.
- SPIFFE / SPIRE (CNCF graduated project): cryptographic workload identities (X.509 and JWT SVIDs) issued automatically and rotated continuously, with no long-lived static secrets.
- OpenID Shared Signals Framework, CAEP and RISC (Final specifications, approved September 2025): real-time security events such as CAEP
session-revokedandcredential-change, or RISCcredential-compromise, pushed between identity providers and applications.
4. The reference lifecycle
Governing NHIs is a lifecycle, not a one-time cleanup. The seven stages below loop continuously, and each one closes specific OWASP risks.
Stage 1: Discover: build a real inventory
You cannot govern what you cannot see. Pull identities from every authority, not just your IdP:
- Entra ID / Okta: app registrations, service principals, enterprise apps, OAuth consent grants.
- Cloud IAM: AWS IAM roles and access keys, Azure managed identities, GCP service accounts and keys.
- CI/CD: GitHub, Azure DevOps and GitLab secrets, service connections, deploy keys.
- Secrets stores and vaults, certificate authorities, Kubernetes service accounts.
- SaaS-to-SaaS integrations and third-party OAuth apps (NHI3).
- Secret scanning across repositories and logs to find what is not registered anywhere (NHI2).
For each identity record at minimum: type, where it authenticates, permissions, credential type and age, last used date, and which system created it.
Stage 2: Own: every identity gets a human owner
An NHI without an owner cannot be reviewed, rotated or retired. Require four attributes at creation and backfill them for existing identities: owner (a person, plus a team), business purpose, data and systems it may touch, and an expiry or review date. Identities nobody claims within a fixed window (for example 30 days) are disabled, then deleted. This alone typically eliminates a large share of NHI1 exposure.
This is where your IGA platform earns its keep: include NHIs and their owners in access certification campaigns, exactly like human access.
Stage 3: Federate: workload identity federation instead of static secrets
The most secure secret is the one that does not exist. Modern platforms let workloads prove who they are using an identity the platform already vouches for, then exchange it for a short-lived token. Use this decision path for every workload:
- Cloud-native workloads → managed identities / IAM roles. The platform issues and rotates short-lived tokens for you; no long-lived credential is stored or managed by your code.
- CI/CD pipelines → OIDC workload identity federation. The pipeline's signed OIDC token is exchanged for a short-lived cloud token; scope the trust to a specific repository, branch or environment, never an entire organization (NHI6).
- Kubernetes, multi-cloud and on-prem services → SPIFFE/SPIRE or platform workload identity, with mutual TLS between services.
- SaaS APIs → OAuth client credentials with
private_key_jwtauthentication (OpenID Connect Core §9, using RFC 7523 JWT assertions) rather than a client secret; keep the private key in an HSM or vault. - Legacy systems with no alternative → a vaulted secret with automated rotation, monitoring and an expiry, and a backlog item to remove it (NHI7).
Stage 4: Constrain: least privilege for service accounts and AI agents
- Scope narrowly: grant permissions on specific resources, not subscriptions or tenants (NHI5). Review cloud "last used" data to remove permissions the identity never exercises.
- Separate environments: distinct identities for dev, test and production; production credentials must never be valid in lower environments (NHI8).
- One identity per workload: no shared service accounts across applications (NHI9).
- Short-lived tokens: minutes to an hour, not months.
- Audience-restricted: request tokens for a specific resource (RFC 8707) so they are rejected anywhere else.
- Sender-constrained: bind tokens to a key with DPoP (RFC 9449) or mTLS (RFC 8705). A leaked bearer token can be replayed by anyone; a leaked bound token is useless without the private key. RFC 9700 §2.2.1 says servers SHOULD use sender-constraining mechanisms.
- Just-in-time privilege: elevated rights (for example, production write access) are granted for a task and expire automatically, through your PAM platform or cloud PIM.
- Block humans from service accounts: conditional access that denies interactive sign-in for NHIs closes NHI10.
Stage 5: Delegate: AI agent authentication with OAuth token exchange (RFC 8693)
The hardest new question is not "what is the agent's identity?" but "whose authority is it using right now?" An agent summarizing a user's tickets must see exactly what that user may see (no more), and every downstream system must be able to tell that an agent, not the person, made the call.
OAuth 2.0 Token Exchange (RFC 8693) was designed for exactly this delegation pattern:
- The user signs in with phishing-resistant MFA, FIDO2/WebAuthn passkeys. Under NIST SP 800-63-4, synced passkeys meet AAL2; AAL3 requires device-bound, non-exportable keys.
- The user asks the agent to perform a task and consents to a narrow scope such as
tickets:read. - The agent calls the token endpoint with a token exchange request: the user's token as the
subject_token, the agent's own workload credential as theactor_token, and the target API as theresource. - The identity provider evaluates policy (is this agent approved, for this user, for this scope, right now?) and issues a token that lives for minutes.
- The authorization server decides what the issued token contains; configure it so the token carries
sub= the user andact= the agent, is audience-restricted to one API, and is bound to the agent's DPoP key. - The API validates signature, audience, expiry, scope, the DPoP proof and the actor chain, then logs both identities.
- If risk changes, the user is disabled, a session is compromised, the IdP pushes a CAEP
session-revokedevent through the Shared Signals Framework, and an API that receives the signal (or checks session state) can reject subsequent calls without waiting for the token to expire. A self-contained JWT that nobody checks stays valid until expiry, keep lifetimes short.
Rule of thumb: an agent should never hold a credential that is more powerful, longer-lived or less traceable than the person it is acting for.
Securing MCP servers with OAuth
The Model Context Protocol's authorization specification builds on OAuth 2.1 (currently an IETF draft). For HTTP-based MCP servers it requires that servers implement Protected Resource Metadata (RFC 9728) and that clients send resource indicators (RFC 8707) in both authorization and token requests, so every token is minted for one specific MCP server. It also forbids token passthrough: MCP servers must not accept or forward tokens that were not issued for them, and clients must not send them other tokens. Authorization is optional in MCP and applies to HTTP transports; local stdio servers take credentials from their environment, so treat those credentials as non-human identities too.
In practice: register every MCP server as an API with an owner, require tokens issued specifically for it, and never let it relay a user's token to another service.
Additional controls for agents:
- Register every agent as its own identity with an owner, identity platforms now offer dedicated agent identities for this (for example, Microsoft Entra Agent ID).
- Prefer read scopes by default; require explicit, step-up user confirmation for write or destructive actions.
- Constrain tools, not just tokens: an agent with a narrow token but an unrestricted shell tool is still overprivileged.
- Treat retrieved content as untrusted input; prompt injection is an authorization problem as much as a model problem.
Stage 6: Evaluate continuously: ITDR for non-human identities
Zero Trust (NIST SP 800-207) requires decisions per session based on current signals, not a one-time grant. For NHIs that means:
- Baseline normal behavior per identity: source IPs or workloads, APIs called, volume, time of day.
- Alert on anomalies, a CI identity used from a laptop, a dormant key suddenly active, a service principal granting itself permissions. This is the domain of identity threat detection and response (ITDR).
- Wire your IdP, SIEM and critical applications together with the Shared Signals Framework so revocation can happen in near real time wherever receivers support it.
- Track posture continuously: credentials past rotation age, unused permissions, identities missing owners.
Stage 7: Retire
Offboarding is where most NHI risk is born. When a project ends, a vendor contract closes, or the owner leaves: revoke tokens and refresh tokens, rotate or delete keys and certificates, remove role assignments and OAuth consents, disable then delete the identity, and keep an audit record. Tie NHI ownership to your HR leaver process so a departing owner triggers reassignment or retirement automatically.
5. Architecture and design
High-level architecture: five layers, three trust boundaries
Before any product choice, agree on the layers. Each layer answers one question, and each must hold on its own, so that when one fails (and eventually one will), the next layer limits the damage.
- Identities: every human, workload and agent that can act, each individually named and owned.
- Trust anchors: how identity is proven: phishing-resistant MFA for people; platform attestation (managed identity, CI OIDC tokens, SPIFFE) for workloads; keys held in HSMs or vaults, never in code. Trust boundary A: nothing proceeds without verified identity.
- Decision: the authorization server decides whether a request gets a token, for which audience and scope, using current risk. Trust boundary B: a token is a time-boxed, scoped decision, not a permanent right.
- Enforcement: every API, gateway and MCP server independently validates every token. Trust boundary C: resources trust tokens, never networks.
- Governance and telemetry: ownership, certification, just-in-time privilege, detection and revocation, feeding risk back into decisions.
Detailed reference architecture
The lifecycle tells you what to govern. The architecture below shows where each control lives. Its core design principle comes straight from NIST SP 800-207 §3: separate the policy decision point (the authorization server that decides who gets a token) from the policy enforcement points (every API, gateway and MCP server that checks the token on every request).
Component responsibilities
- Workload identity issuers: cloud managed-identity endpoints, a SPIRE server, or a CI/CD OIDC issuer. They vouch for what a workload is (this repository, this Kubernetes service account, this VM) and issue a short-lived, verifiable credential. Nothing long-lived is stored in the workload.
- Authorization server (policy decision point): your IdP's OAuth token endpoint. It authenticates clients with assertions (
private_key_jwtor federated tokens), performs token exchange for agents, evaluates policy, and mints audience-restricted, sender-constrained tokens. - Policy enforcement points: API gateways, service meshes, MCP servers and the APIs themselves. They validate signature, issuer, expiry, audience, binding (DPoP or mTLS), scope and the actor chain on every request, and log both the subject and the actor.
- Secrets manager: holds only the legacy exceptions, rotates them automatically, and logs every read.
- Shared Signals transmitter/receivers: move revocation and risk events between the IdP and applications in near real time where supported.
- IGA, PAM and SIEM/ITDR: ownership and certification, just-in-time privilege, and detection. Their signals feed back into the policy decision point.
Design decisions and trade-offs
- Token lifetime: ≤ 60 minutes for workloads, ≤ 5 minutes for agent-delegated tokens. Shorter lifetimes reduce the damage of a stolen token and the need for real-time revocation; the cost is more token requests, which token caching per audience absorbs.
- DPoP vs. mTLS for sender-constraining: choose mTLS (RFC 8705) where you already run a service mesh or PKI; choose DPoP (RFC 9449) for agents, browsers and SaaS calls where client certificates are impractical. Both satisfy RFC 9700's recommendation.
- Exchange, never forward: an agent or MCP server that needs to call a downstream API obtains a new token for that audience via token exchange; it never relays the inbound token. This preserves audience restriction and the actor trail.
- One identity per workload per environment: more identities to manage, but blast radius and accountability are bounded (OWASP NHI8, NHI9). Automate creation through infrastructure-as-code so the overhead stays low.
- Federation trust scope: trust the narrowest subject the platform supports, a specific repository and environment or branch, rather than an organisation or a wildcard.
Failure modes to design for
- IdP or token endpoint outage: already-issued tokens keep working until expiry, so short lifetimes mean a short grace period. Decide per system whether it fails closed (default for privileged operations) and document a break-glass path with its own monitoring.
- Signal not received: Shared Signals delivery can fail or a receiver may not support it. Short token lifetimes are the backstop, never rely on revocation alone.
- Clock skew: token and DPoP validation depend on time. Keep NTP healthy and allow only a small, explicit skew window.
- Key compromise at the issuer: rotate signing keys on a schedule, publish them via JWKS, and rehearse emergency rotation.
6. Use cases: choosing the right pattern, and when it breaks
No single pattern covers every non-human identity. For each common use case below: the pattern to use, the condition under which that pattern stops protecting you, and the guardrail that covers the gap.
UC-1: CI/CD pipeline deploying to cloud
- Flow: (1) job starts in the protected
productionenvironment → (2) GitHub issues a signed OIDC token → (3) Entra matches the repository + environment subject → (4) a short-lived cloud token is issued → (5) the job deploys to one resource. - Pattern: OIDC workload identity federation, trust scoped to repository + environment; deploy job only.
- Breaks when: trust is scoped too broadly (organisation or wildcard subject), or a compromised step inside the trusted job requests the token itself.
- Guardrail: exact subject match, protected environments with reviewers, actions pinned to commit SHAs,
id-token: writegranted only to the deploy job (see Threat T-5).
UC-2: Service-to-service inside Kubernetes or across clouds
- Flow: (1) SPIRE attests the node and the workload → (2) an auto-rotated SVID is issued → (3) services complete a mutual-TLS handshake → (4) the callee authorizes by SPIFFE ID → (5) the call is allowed or denied.
- Pattern: SPIFFE/SPIRE (or platform workload identity) with mutual TLS; authorization by SPIFFE ID, not IP address.
- Breaks when: node attestation is weak, so any pod on a compromised node can obtain another workload's identity.
- Guardrail: strong node and workload attestation selectors, one SPIFFE ID per workload, short SVID lifetimes, and network policies as a second layer.
UC-3: Cloud function or VM calling a cloud API
- Flow: (1) code runs on the platform → (2) it calls the local identity endpoint → (3) the platform issues a short-lived token → (4) a resource-scoped role is evaluated → (5) the API call proceeds.
- Pattern: managed identity / IAM role with resource-scoped permissions.
- Breaks when: the identity is assigned broad roles "to make it work", or anyone who can run code on the host (SSRF, compromised dependency) can call the local token endpoint.
- Guardrail: resource-scoped roles reviewed with last-used data, SSRF protections, and on AWS the IMDSv2 session-token requirement.
UC-4: SaaS-to-SaaS and third-party integrations
- Flow: (1) an admin-approved app → (2) signs a JWT assertion with its private key → (3) requests a client-credentials token → (4) with the minimal application permission → (5) and calls the vendor API.
- Pattern: OAuth client credentials with
private_key_jwt; admin-approved, minimal application permissions. - Breaks when: users can consent to risky apps themselves, or the vendor is breached and its token becomes yours.
- Guardrail: restrict user consent, admin consent workflow, quarterly review of third-party app permissions, an owner for every integration (Threats T-2, T-3).
UC-5: AI agent acting for a signed-in user
- Flow: (1) the user signs in with a passkey → (2) consents to a narrow scope → (3) the agent performs a token exchange → (4) receives a ≤ 5-minute, audience- and DPoP-bound token → (5) the API checks
sub(user) andact(agent). - Pattern: token exchange (RFC 8693) producing a ≤ 5-minute, audience-bound, DPoP-bound token with
sub= user andact= agent. - Breaks when: the agent is prompt-injected into using its legitimate access for an attacker's purpose, the token is valid, the intent is not.
- Guardrail: read-only scopes by default, explicit user confirmation for writes, tool allow-lists (Threat T-9).
UC-6: Autonomous agent with no user in the loop
- Flow: (1) the agent authenticates with its own workload identity → (2) receives a task-scoped token → (3) rate and spend limits apply → (4) high-impact actions wait for human approval → (5) disabling the identity is the kill switch.
- Pattern: the agent's own workload identity with narrow, task-specific scopes (client credentials), never a human's credentials.
- Breaks when: there is no human "ceiling" on what it can do, so its permissions are the blast radius.
- Guardrail: human approval for high-impact actions, rate and spend limits, an owner, and a tested kill switch (Threat T-12).
UC-7: Agent-to-agent orchestration
- Flow: (1) agent A receives a task → (2) exchanges for a narrower-scoped token → (3) agent B receives a token with a nested
act→ (4) the maximum delegation depth is enforced → (5) the full chain is logged. - Pattern: each hop performs its own token exchange, narrowing audience and scope; RFC 8693 allows nested
actclaims to preserve the full chain (nested actors are informational only, authorization decisions use the current actor). - Breaks when: a downstream agent receives more authority than the upstream request needed, or the chain becomes too deep to audit.
- Guardrail: scope can only shrink at each hop, a maximum delegation depth enforced by policy, and logging of the full actor chain (Threat T-11).
UC-8: MCP tool server exposing internal systems
- Flow: (1) the server is on the approved allow-list → (2) the client reads its Protected Resource Metadata → (3) obtains a token issued for this server only → (4) each tool call is checked against its scope → (5) the server never forwards the token.
- Pattern: treat it as an OAuth-protected API: Protected Resource Metadata, tokens issued specifically for it, no token passthrough.
- Breaks when: an unapproved or compromised MCP server is connected, or tool descriptions contain hidden instructions.
- Guardrail: an allow-list of approved servers with pinned versions and owners, review of tool descriptions, least-privilege per tool (Threat T-10).
UC-9: Legacy system or batch job that only supports a password or key
- Flow: (1) the exception is approved with an expiry → (2) the secret lives in the vault → (3) it is fetched at runtime → (4) rotated automatically every ≤ 90 days → (5) and every use is monitored.
- Pattern: vaulted secret, automated rotation, owner and expiry, network restrictions on where it may be used.
- Breaks when: the "temporary" exception becomes permanent and the secret is copied out of the vault.
- Guardrail: exceptions expire automatically, use is monitored, and a modernisation ticket is tracked to closure.
UC-10: Vendor or contractor automation in your tenant
- Flow: (1) a dedicated identity per vendor and purpose → (2) access requested through PAM/JIT → (3) time-boxed approval → (4) the session is logged → (5) access expires with the contract.
- Pattern: a dedicated identity per vendor and purpose, time-bound access through PAM/JIT, contractually defined offboarding.
- Breaks when: the contract ends but the identity and its credentials do not (OWASP NHI1).
- Guardrail: expiry dates tied to the contract, quarterly certification by an internal owner.
7. Threat model: what if the architecture is attacked?
A design is only as good as its behaviour under attack. Each scenario below states plainly why the baseline architecture is not enough on its own, then the defences, how to detect it, and the test that proves the defence works. Several are drawn from publicly documented incidents.
T-1: The token-signing key is stolen
- Real-world precedent: in the 2023 Storm-0558 intrusion, an attacker used an acquired, inactive Microsoft consumer (MSA) signing key to forge tokens for both consumer and enterprise accounts, reaching Outlook.com and Outlook Web Access mailboxes. A validation flaw let a key meant only for consumer accounts be accepted for enterprise tokens.
- Why the baseline fails: every enforcement point trusts the signature. A forged token can carry any audience, scope or proof-of-possession binding the attacker chooses, sender-constraining does not help against a forger.
- Defend: signing keys in HSMs with rotation; resource servers accept a key only for its expected issuer and tenant; short lifetimes; minimise which systems trust which issuers.
- Detect: correlate tokens used at resources with tokens actually issued; alert on unknown key IDs or impossible claim combinations.
- Test: TC-19.
T-2: A forgotten privileged OAuth application
- Real-world precedent: in the 2024 Midnight Blizzard attack on Microsoft, a password-sprayed account in a legacy, non-production test tenant without MFA led to a legacy test OAuth application with elevated access to the corporate environment. The attacker used it to create malicious OAuth apps and grant them Exchange Online's
full_access_as_approle, which let it read corporate mailboxes. - Why the baseline fails: the application was a legitimate, already-consented identity, no stolen secret was needed at the resource.
- Defend: inventory app registrations in every tenant including test; MFA for all admin accounts everywhere; owners and expiry on apps; remove unused high-privilege application permissions.
- Detect: alert on new credentials added to apps, new high-privilege app role assignments, and new apps granted mail or directory write permissions.
- Test: TC-20.
T-3: Illicit consent grant (consent phishing)
- Why the baseline fails: a user is tricked into consenting to a malicious multi-tenant app; the app then receives valid tokens through a perfectly normal OAuth flow.
- Defend: restrict user consent (for example, to verified publishers and low-risk permissions only) and route everything else through an admin consent workflow.
- Detect: review new consent grants and service principals daily; alert on consents to unverified publishers.
- Test: TC-21.
T-4: Federation trust scoped too broadly
- Why the baseline fails: federation is only as narrow as its subject condition. Trusting an entire organisation, a wildcard, or any branch lets an attacker with write access to any matching repository or branch mint production tokens.
- Defend: exact subject matching on repository and environment; protected environments with required reviewers; avoid running untrusted pull-request code in privileged workflow contexts such as
pull_request_target. - Detect: periodically export federated credentials and flag any without an exact subject.
- Test: TC-02.
T-5: A compromised dependency inside the trusted pipeline
- Real-world precedent: in March 2025 the widely used
tj-actions/changed-filesGitHub Action was compromised (CVE-2025-30066) and modified to expose CI/CD secrets in workflow logs. - Why the baseline fails: federation removes stored secrets, but malicious code running inside the trusted job can still request the job's OIDC token and use the resulting cloud token while it is valid.
- Defend: pin third-party actions to full commit SHAs; grant
id-token: writeonly to the deploy job and keep third-party steps out of it; separate build and deploy jobs; ephemeral runners; restrict runner network egress; short-lived cloud tokens with least privilege. - Detect: deployments outside approved runs; cloud sign-ins from the federated identity outside expected workflow runs.
- Test: TC-22.
T-6: Bearer token stolen from logs, memory or a proxy
- Why the baseline fails: a plain bearer token works for whoever holds it until it expires.
- Defend: sender-constrain tokens (DPoP or mTLS); never log tokens or authorization headers; keep proof-of-possession keys non-exportable (TPM, HSM, secure enclave) where possible, if the attacker owns the host and can use the key, binding no longer helps, so lifetimes must stay short.
- Detect: secret scanning on logs; token use from unexpected clients or networks.
- Test: TC-07, TC-23.
T-7: Long-lived refresh token held by an agent
- Why the baseline fails: short access tokens are pointless if a stolen refresh token can mint new ones for months.
- Defend: avoid refresh tokens for agents where possible; otherwise sender-constrain them or use refresh-token rotation (RFC 9700), with absolute lifetimes and revocation on risk.
- Detect: refresh-token reuse (a rotated token presented again indicates theft).
- Test: TC-24.
T-8: Human uses a service account
- Why the baseline fails: service credentials bypass the MFA and approvals that apply to people (OWASP NHI10).
- Defend: block interactive sign-in for NHIs; location- or network-based conditional access for workload identities where your IdP supports it (in Microsoft Entra this needs Workload Identities Premium and covers single-tenant service principals, not managed identities); PAM for any break-glass use.
- Detect: interactive or browser-based sign-ins by service identities.
- Test: TC-04.
T-9: Prompt injection turns the agent into a confused deputy
- Why the baseline fails: the agent's token is legitimate; the instructions it follows came from untrusted content (a web page, email or document).
- Defend: least-privilege scopes; separate read and write agents; explicit user confirmation for writes, payments or external sends; allow-listed tools and destinations; treat all retrieved content as untrusted input.
- Detect: agent actions that deviate from the user's request; spikes in write or outbound calls.
- Test: TC-14.
T-10: Malicious or compromised MCP server
- Why the baseline fails: the client trusts whatever server it is connected to, including tool descriptions that embed hidden instructions, or a server that silently changes behaviour after approval.
- Defend: an allow-list of approved MCP servers with owners and pinned versions; review tool descriptions on every change; per-server, audience-bound tokens so a rogue server cannot reuse them elsewhere; no token passthrough.
- Detect: connections to unapproved servers; tool-definition changes.
- Test: TC-15, TC-25.
T-11: Authority amplification in agent chains
- Why the baseline fails: if each agent forwards its full authority, the last agent in a chain holds everything the first one had, for every downstream API.
- Defend: exchange at every hop; scopes and audiences may only narrow; enforce a maximum delegation depth; record the full
actchain. - Detect: tokens with unexpectedly deep actor chains or broader scope than their parent.
- Test: TC-26.
T-12: Autonomous agent goes wrong at machine speed
- Why the baseline fails: with no human in the loop, a bug or manipulation repeats thousands of times before anyone notices.
- Defend: rate and spend limits, human approval thresholds for high-impact actions, and a kill switch, disabling the agent's identity, that has been rehearsed.
- Detect: volume and error-rate anomalies per agent identity.
- Test: TC-27.
T-13: Identity provider outage leads to permanent "temporary" fixes
- Why the baseline fails: under pressure, teams create static keys "just for today" that remain for years.
- Defend: a break-glass process designed in advance, time-boxed credentials in PAM, dual approval, automatic expiry.
- Detect: alert on any break-glass use and on credentials created outside the standard pipeline.
- Test: TC-28.
T-14: Revocation does not reach the resource
- Why the baseline fails: many resources do not yet receive Shared Signals; a revoked session's token keeps working until it expires.
- Defend: short lifetimes as the primary control; SSF/CAEP where supported; token introspection for the highest-risk APIs.
- Detect: requests from disabled identities that still succeed.
- Test: TC-16.
T-15: Development identity reaches production
- Why the baseline fails: shared identities across environments let a weakly protected test system become a path into production (OWASP NHI8).
- Defend: separate identities, tenants or subscriptions per environment; production audiences never accepted from non-production issuers.
- Detect: production access by identities tagged non-production.
- Test: TC-29.
Defence in depth at a glance
- Layer 2 (trust anchors) stops stored-secret theft (T-6, T-9 in part) and limits forgery impact through key protection (T-1).
- Layer 3 (decision) stops over-broad federation (T-4), consent abuse (T-3) and authority amplification (T-11).
- Layer 4 (enforcement) stops replay, audience confusion and passthrough (T-6, T-10, T-14).
- Layer 5 (governance and telemetry) catches what slips through: forgotten apps (T-2), compromised pipelines (T-5), agents misbehaving (T-9, T-12) and break-glass misuse (T-13).
8. Worked example: remove a stored secret from a GitHub Actions → Azure pipeline
This is one of the most common real-world NHI exposures: a pipeline that deploys to Azure using a service principal client secret stored as a repository secret. That secret is long-lived (NHI7), often over-privileged (NHI5), and usable from anywhere if it leaks (NHI2). Microsoft Entra workload identity federation removes it entirely: GitHub issues a signed OIDC token for each job, and Entra exchanges it for a short-lived Azure token, but only for the repository and environment you trust.
Step 1, Create the identity and trust only the production environment
# Create the app registration and its service principal
az ad app create --display-name "gh-payments-api-prod-deploy"
az ad sp create --id <APP_ID>
# Trust GitHub's OIDC issuer, for ONE repository and ONE environment only
az ad app federated-credential create --id <APP_ID> --parameters '{
"name": "github-payments-api-production",
"issuer": "https://token.actions.githubusercontent.com",
"subject": "repo:CONTOSO/payments-api:environment:production",
"audiences": ["api://AzureADTokenExchange"]
}'
Step 2, Grant least privilege on the single resource it deploys
az role assignment create --assignee <APP_ID> --role "Website Contributor" --scope /subscriptions/<SUB_ID>/resourceGroups/rg-payments-prod/providers/Microsoft.Web/sites/payments-api-prod
Not Contributor on the subscription, only the built-in role needed to deploy one web app, on that one web app.
Step 3, Update the workflow to request an OIDC token
permissions:
id-token: write # allow this job to request a GitHub OIDC token
contents: read
jobs:
deploy:
runs-on: ubuntu-latest
environment: production # must match the federated credential subject
steps:
- uses: actions/checkout@v4
- uses: azure/login@v3
with:
client-id: ${{ vars.AZURE_CLIENT_ID }}
tenant-id: ${{ vars.AZURE_TENANT_ID }}
subscription-id: ${{ vars.AZURE_SUBSCRIPTION_ID }}
- run: az webapp deploy --resource-group rg-payments-prod --name payments-api-prod --src-path app.zip
The client, tenant and subscription IDs are identifiers, not credentials, Microsoft's examples store them as secrets, but repository variables are acceptable because they grant nothing without a matching federated token. Protect the production environment with required reviewers so a deployment also needs human approval.
Step 4, Delete the old secret
# Find and delete any client secrets left on the app
az ad app credential list --id <APP_ID>
az ad app credential delete --id <APP_ID> --key-id <KEY_ID>
Then remove the old AZURE_CREDENTIALS (or similar) secret from the repository and organisation settings.
Step 5, Prove it worked
- Positive test: a run of the workflow in the
productionenvironment logs in and deploys successfully. - Wrong context is rejected: a run from a branch job without the
productionenvironment presents a different subject claim; Entra rejects it withAADSTS700213: No matching federated identity record found for presented assertion subject. Pull requests from forks are not grantedid-token: writeat all. - Least privilege holds: from the pipeline, an operation outside the scope (for example, reading another resource group) fails with
AuthorizationFailed. - No secret remains:
az ad app credential list --id <APP_ID>returns an empty list, and secret scanning finds no Azure credentials in the repository. - Audit trail: the run appears in Entra sign-in logs under Service principal sign-ins, with the client credential type shown as Federated identity credential.
The same pattern applies to AWS (an IAM OIDC identity provider plus a role trust policy with conditions on token.actions.githubusercontent.com:sub and :aud = sts.amazonaws.com) and Google Cloud (Workload Identity Federation with an attribute condition such as the repository name).
9. Security test cases to validate the controls
A control you have not tested is an assumption. Run these as part of acceptance testing and repeat the automatable ones in CI. Expected results describe correct behaviour; exact error codes vary by product.
Federation and credentials
- TC-01: Trusted context succeeds. Run the federated workload from its approved repository/environment. Expected: short-lived token issued; no stored secret used. Maps to: NHI7.
- TC-02: Untrusted context fails. Run the same workflow from another branch, environment or a fork. Expected: token request rejected (subject claim mismatch). Maps to: NHI6.
- TC-03: No static secrets remain. List credentials on each migrated identity and run secret scanning on repositories and build logs. Expected: none found. Maps to: NHI2, NHI7.
- TC-04: Interactive sign-in blocked. Attempt an interactive login as a service account. Expected: blocked by policy and alerted. Maps to: NHI10.
Token validation at the enforcement point
- TC-05: Wrong audience rejected. Send a valid token issued for API A to API B. Expected:
401withinvalid_token. Maps to: RFC 8707, RFC 9700. - TC-06: Expired token rejected. Replay a token after its
exp. Expected:401. Maps to: NIST SP 800-207 per-session access. - TC-07: Unbound use of a DPoP-bound token rejected. Present a DPoP-bound access token without a DPoP proof, or with a proof signed by a different key. Expected:
401with aWWW-Authenticate: DPoPchallenge (invalid_dpop_proofwhen the proof is signed by the wrong key). Maps to: RFC 9449. - TC-08: DPoP proof replay rejected. Resend an identical DPoP proof (same
jti) or one with a mismatchedhtm/htu. Expected:401withWWW-Authenticate: DPoP error="invalid_dpop_proof". Maps to: RFC 9449 §7.1, §11.1. - TC-09: Insufficient scope rejected. Call a write endpoint with a read-only token. Expected:
403withinsufficient_scope. Maps to: NHI5, RFC 6750. - TC-10: Implicit grant disabled. Send an authorization request with
response_type=token. Expected: refused withunsupported_response_type(RFC 6749 §4.2.2.1) orunauthorized_client. Maps to: RFC 9700.
AI agent delegation and MCP
- TC-11: Delegated token carries the actor. Perform a token exchange for an approved agent. Expected: issued token has
sub= user,act= agent, audience = target API, lifetime ≤ 5 minutes. Maps to: RFC 8693. - TC-12: Unapproved agent or resource refused. Request an exchange for an agent not approved for that user, or for a resource outside policy. Expected: error (for example
invalid_targetfor a disallowed resource). Maps to: RFC 8693 §2.2.2. - TC-13: Agent cannot exceed the user. Ask the agent for data the delegating user is not entitled to. Expected: API returns only the user's permitted data. Maps to: NHI5.
- TC-14: Prompt-injected write is blocked. Have the agent read a document containing instructions to call a delete endpoint. Expected: the call fails with
insufficient_scopeor requires explicit user confirmation. Maps to: least privilege for agents. - TC-15: MCP server rejects foreign tokens. Send an MCP server a token issued for a different resource. Expected:
401; the server never forwards it downstream. Maps to: MCP authorization specification (no token passthrough).
Revocation, lifecycle and detection
- TC-16: Revocation propagates. Disable a user who has an active agent session. Expected: receivers that support Shared Signals reject further calls; all others fail at token expiry (≤ 5 minutes). Maps to: CAEP.
- TC-17: Orphaned identities are caught. Mark an NHI owner as a leaver in HR. Expected: identity flagged for reassignment and disabled if unclaimed within the agreed window. Maps to: NHI1.
- TC-18: Anomalous use is detected. Use a CI identity from an unexpected network or a dormant credential suddenly. Expected: ITDR alert raised within the agreed SLA. Maps to: NIST SP 800-207 continuous monitoring.
Abuse cases from the threat model
- TC-19: Cross-issuer key rejected. Present a token whose signing key belongs to a different issuer or tenant than the
issclaim. Expected:401. Maps to: T-1. - TC-20: New app credentials raise an alert. Add a client secret or certificate to an existing app registration in a test tenant. Expected: alert within the agreed SLA, with owner notified. Maps to: T-2.
- TC-21: Risky consent is blocked. As a standard user, attempt to consent to an unverified multi-tenant app requesting mail access. Expected: consent blocked or routed to the admin consent workflow. Maps to: T-3.
- TC-22: Unpinned third-party actions fail policy. Open a pull request that references a third-party action by tag instead of a full commit SHA, or grants
id-token: writeto a build job. Expected: CI policy check fails. Maps to: T-5. - TC-23: Tokens never reach logs. Run each service with verbose logging and scan the output for bearer tokens, JWTs and authorization headers. Expected: none found. Maps to: T-6, NHI2.
- TC-24: Refresh-token reuse is detected. Use a refresh token, then present the already-rotated one again. Expected: rejected and the token family revoked or flagged. Maps to: T-7, RFC 9700.
- TC-25: Unapproved MCP server blocked. Configure an agent to connect to an MCP server that is not on the allow-list. Expected: connection refused and logged. Maps to: T-10.
- TC-26: Delegation cannot widen or exceed max depth. Request an exchange whose scope is broader than the incoming token, or that would exceed the maximum delegation depth. Expected: refused. Maps to: T-11.
- TC-27: Kill switch works. Disable an autonomous agent's identity during a run. Expected: no new tokens issued immediately; in-flight tokens stop working at the latest when they expire. Maps to: T-12.
- TC-28: Break-glass use is time-boxed and alerted. Exercise the break-glass procedure. Expected: alert raised, credential expires automatically, post-use review recorded. Maps to: T-13.
- TC-29: Non-production identities cannot reach production. Attempt to call a production API with a token from a development identity or issuer. Expected:
401/403. Maps to: T-15, NHI8.
Reference request: token exchange for an agent
POST /oauth2/token HTTP/1.1
Host: idp.example.com
Content-Type: application/x-www-form-urlencoded
DPoP: <proof JWT signed with the agent's key>
grant_type=urn:ietf:params:oauth:grant-type:token-exchange
&subject_token=<user access token>
&subject_token_type=urn:ietf:params:oauth:token-type:access_token
&actor_token=<agent workload credential>
&actor_token_type=urn:ietf:params:oauth:token-type:jwt
&resource=https://tickets.example.com
&scope=tickets:read
Parameter names and token-type URIs are defined in RFC 8693; the DPoP header is defined in RFC 9449. Exact support for token exchange and DPoP varies by identity provider, confirm in your vendor's documentation before designing around it.
10. A 90-day implementation plan
Days 1 to 30: Visibility and quick wins
- Build the inventory across IdP, cloud, CI/CD and vaults; run secret scanning on all repositories.
- Rotate any secret found in code or logs and purge it from history.
- Block interactive sign-in for service accounts; disable identities unused for 90+ days (after owner notification).
- Freeze creation of new static secrets without an exception approval.
Days 31 to 60: Ownership and federation
- Assign owners, purpose and expiry to every remaining identity; retire the unclaimed.
- Move CI/CD to OIDC workload federation and cloud workloads to managed identities.
- Replace client secrets with
private_key_jwtfor SaaS integrations that support it. - Include NHIs in your next access certification campaign.
Days 61 to 90: Agents and continuous control
- Register all AI agents and MCP servers as identities with owners and approved scopes.
- Implement delegated, audience-bound, short-lived tokens for agents (token exchange) instead of shared API keys.
- Enable sender-constrained tokens (DPoP or mTLS) for high-value APIs.
- Stream identity events to your SIEM, define ITDR detections, and connect revocation via Shared Signals / CAEP where supported.
11. How to measure progress
- Percentage of NHIs with a named owner and expiry date (target: 100%).
- Percentage of workloads using federation or managed identity instead of static secrets.
- Median and maximum credential age; number of credentials older than 90 days.
- Number of NHIs with privileged roles, and how many were granted just-in-time.
- Mean time to revoke a compromised credential.
- Percentage of AI agents using delegated, audience-bound tokens.
12. Common mistakes to avoid
- Treating it as a secrets-manager project only. A vault stores secrets better; federation removes them. Do both, in that order of preference.
- Federating too broadly. Trusting "any pipeline in our GitHub organization" is a static secret with extra steps. Scope trust to repository, branch and environment.
- Giving agents the user's raw token. Token passthrough loses the actor trail and the audience restriction. Exchange, don't forward.
- Long-lived refresh tokens for agents. If an agent needs durable access, it needs an owner, a review cycle and a revocation path, not a token that never dies.
- Skipping the humans. Delegation is only as strong as the person delegating: phishing-resistant MFA for the people who own and instruct agents is part of the control.
13. Where SynoCores helps
SynoCores' identity and access management practice implements this blueprint across Microsoft Entra, Okta, Ping Identity, SailPoint, Saviynt and PAM platforms, from NHI discovery and ownership campaigns to workload identity federation, AI agent identity design and ITDR detections. Need specialists on your team instead? See our IAM staffing. For a second opinion on your current state, book a 30-minute discovery call, or send us your requirements and we will reply within one business day.
References
All standards, specifications and vendor documentation below were reviewed for currency in November 2026.
- NIST SP 800-207: Zero Trust Architecture
- NIST SP 800-63-4: Digital Identity Guidelines
- RFC 9700: Best Current Practice for OAuth 2.0 Security
- RFC 8693: OAuth 2.0 Token Exchange
- RFC 8707: Resource Indicators for OAuth 2.0
- RFC 9449: OAuth 2.0 Demonstrating Proof of Possession (DPoP)
- RFC 8705: OAuth 2.0 Mutual-TLS Client Authentication and Certificate-Bound Access Tokens
- RFC 7523: JWT Profile for OAuth 2.0 Client Authentication and Authorization Grants
- RFC 9728: OAuth 2.0 Protected Resource Metadata
- SPIFFE: Secure Production Identity Framework for Everyone
- OpenID Shared Signals Working Group (SSF, CAEP, RISC)
- OpenID Continuous Access Evaluation Profile (CAEP) 1.0: Final
- The OAuth 2.1 Authorization Framework (IETF draft)
- OWASP Non-Human Identities Top 10
- Microsoft Entra: Workload identity federation
- GitHub Actions: OpenID Connect
- Azure/login GitHub Action
- RFC 6750: OAuth 2.0 Bearer Token Usage (error codes)
- Microsoft: Analysis of Storm-0558 techniques for unauthorized email access (2023)
- Microsoft: Midnight Blizzard: guidance for responders (2024)
- CISA: Supply chain compromise of tj-actions/changed-files (CVE-2025-30066)
- Model Context Protocol: 2026-07-28 specification release
- GitHub Advisory: MCP TypeScript SDK OAuth credential exposure (CVE-2026-104850)
- OWASP Top 10 for Agentic Applications for 2026
- NIST NCCoE: Accelerating the Adoption of Software and AI Agent Identity and Authorization (2026)
- NIST IR 8587: Protecting Tokens and Assertions from Forgery, Theft, and Misuse (2026)
- IETF draft: OAuth Transaction Tokens
- Microsoft Entra Agent ID: what's new
- Okta: Agent SSO with Cross App Access (2026)
- Microsoft Entra: Conditional Access for workload identities
- Model Context Protocol: Authorization specification