TL;DR: An AI agent can exchange a short-lived SPIFFE-based JWT for an Anthropic access token, removing the need to store a reusable API key on the machine and limiting replay to a single use, according to Testifysec. That shifts the control point from leaked secrets to federated trust, which matters whenever agents operate outside tightly managed runtimes.
At a glance
What this is: NHI Mgmt Group's analysis, drawing on Testifysec's blog post: Anthropic workload identity federation lets an AI agent trade a short-lived trusted token for API access, eliminating the reusable API key exposure pattern.
Why it matters: IAM, PAM, and NHI teams need to understand that agent access risk moves from secret storage to federation rules, token audience scoping, and replay resistance.
By the numbers:
- 96% of organisations store secrets outside of secrets managers in vulnerable locations including code, config files, and CI/CD tools, according to the Ultimate Guide to NHIs.
- 80% of identity breaches involved compromised non-human identities such as service accounts and API keys, according to the Ultimate Guide to NHIs.
Context
A workload identity pattern replaces a shared secret with a short-lived, verifiable assertion about the caller. In this case, the important governance shift is that the agent no longer needs a reusable Anthropic API key sitting in an environment variable or config file, which reduces the number of places an identity credential can leak.
For agent programmes, the real question is not whether the model can call an API. It is whether the authentication design can survive the realities of machine-run execution, including token replay, audience restriction, and delegated trust between the platform and the relying party.
Key questions
Q: Why do static API keys create risk for AI agent access?
A: Static API keys create risk because they are long-lived, reusable, and difficult to tie to a specific action. In an agentic environment, that means the same secret can be replayed across tools, sessions, or workloads long after the original task is complete. Short-lived delegated credentials give teams a much better chance of limiting scope and preserving accountability.
Q: Why do short-lived federated tokens reduce agent identity risk?
A: They narrow the window in which a copied credential remains useful and can be bound to one issuer, one subject, and one audience. That limits replay, reduces the impact of leakage, and forces trust decisions to happen at issuance time rather than after a secret has spread.
Q: How should teams govern audience scoping for agent credentials?
A: Treat audience scoping as part of entitlement design, not a token detail. Each agent trust rule should name the exact relying party and approved subject pattern, because broad or missing audiences turn a federation issuer into a general-purpose token source.
Q: What should security teams do first when agent API keys are still in use?
A: Start by finding every place the key can persist, then remove the durable secret from the runtime path before expanding federation. If the key is still present in files or variables, the exposure problem remains even if rotation and logging controls improve.
Technical breakdown
How workload identity federation replaces long-lived API keys
Workload identity federation lets one system prove its identity to another using a short-lived token issued by a trusted identity provider. In the pattern described here, the agent first authenticates to the platform, then receives a brief JWT that Anthropic can validate against published keys and a federation rule. That means the external service trusts the issuer, the subject, and the audience rather than a static secret copied onto the host. The security benefit comes from removing the reusable credential from the machine and binding access to a specific trust relationship. See the NHI Authentication Guide.
Practical implication: Treat federation as an identity design decision, not just a transport mechanism, and scope each trust relationship to one relying party.
Why single-use tokens change the replay model
The article's replay test matters because it shows the token is designed to fail closed after first use. A single-use JWT with a short lifetime reduces the value of a copied credential in logs, process listings, or shell history. That does not eliminate misuse, but it sharply narrows the attack window and prevents one captured token from becoming a reusable bearer credential. For identity teams, this is the difference between a leaked secret that persists and a transient assertion that dies with the exchange. See the API Key Management Guide.
Practical implication: Design agent authentication so a captured token is useless after first presentation, then monitor for repeated exchange attempts.
How audience allowlists constrain agent trust
Audience scoping keeps the token tied to one relying party and one approved use case. In the article, the platform refused to mint a token for any audience outside the allowlist, which prevents a valid platform-issued token from being reused against a different service. This is a governance boundary, not just a protocol detail. Without it, the federation issuer becomes a generic token factory, and the trust relationship expands beyond the intended service boundary. The control is therefore as much about entitlement definition as it is about cryptography. Read the Ultimate Guide to NHIs: What are Non-Human Identities.
Practical implication: Define per-service audience allowlists and review them as part of NHI entitlement governance.
Threat narrative
Attacker objective: Use a copied Anthropic credential to impersonate an agent and access Anthropic services from an unauthorised environment.
- Entry begins when an AI agent holds a reusable Anthropic API key in an environment variable or config file that can be copied from any machine.
- Credential exposure occurs when that key leaks through ordinary runtime surfaces such as logs, files, or process state, making the same credential reusable elsewhere.
- Impact follows when the leaked credential is replayed to call Anthropic APIs from an unauthorised context, extending access beyond the intended machine and lifecycle.
Breaches seen in the wild
- ConnectWise Cloud Backup breach 2026: A stolen ConnectWise Cloud Backup app secret gave attackers sign-ins to 160+ Microsoft 365 tenants, then admin roles via sibling service principals.
Read and download The State of NHI & AI Agent Breach Report 2026, covering 200+ breaches impacting Non-Human Identities including AI Agents.
NHI Mgmt Group analysis
Federated token exchange is a credential-design shift, not an AI feature: The central change is that the agent no longer carries a durable Anthropic API key through its runtime. That pushes identity governance away from secret storage and toward issuer trust, audience scope, and expiry management. The practitioner conclusion is straightforward: if the credential can be copied and reused, the design has not yet moved far enough.
Long-lived secrets are the wrong trust primitive for machine-run agents: This article reinforces that API keys behave like portable identity artefacts, which is exactly why they leak across environments. The important governance point is not that rotation is hard, but that rotation alone does not solve the portability problem. Practitioners should treat any design that depends on a shared secret surviving in a file or variable as structurally fragile.
Single-use assertions create a narrower identity blast radius: A copied JWT that fails after first use limits the consequences of exposure, especially when the issuer also enforces audience restrictions. That does not remove the need for inventory, ownership, and revocation, but it changes the control objective from preserving a secret to containing a trust event. The practitioner implication is that machine identity programmes should privilege short-lived, bounded assertions over reusable credentials.
Identity governance for agents now depends on policy quality, not just secret hygiene: The article shows that the security rule lives in the federation mapping, where the subject prefix and audience must both be correct. That means weakly scoped allowlists can create the same exposure as a leaked key, just through a policy flaw rather than a secret leak. The conclusion for identity teams is to audit federation rules with the same seriousness as privileged access policies.
For agent identity, access review assumptions still need to be challenged: This pattern works because the agent can acquire, use, and discard a short-lived credential inside one workflow. That compresses the reviewable window and makes static recertification less useful than issuance-time controls and trust-boundary checks. The implication is that agent governance should be measured by how tightly access is bound to task scope, not by how many secrets have been catalogued.
From our research library:
- DeepSeek alone generated 113,000 new exposed API keys in 2025, illustrating how new AI providers create credential exposure before security guardrails catch up, according to the State of Secrets Sprawl 2026.
- Only 20% have formal processes for offboarding and revoking API keys, and even fewer have procedures for rotating them, according to the Ultimate Guide to NHIs.
- Read next: NHI Authentication Guide
What this signals
Ephemeral agent access changes the governance unit: teams should stop thinking about agent credentials as durable assets and start thinking about issuance events, audience boundaries, and token provenance. Once access is single-use and short-lived, the control objective shifts from periodic review to tightly governed trust establishment.
The more agent programmes rely on federated exchange, the more policy quality matters. A weak subject pattern or overly broad audience allowlist can recreate the same exposure that secret sprawl caused, but through trust misconfiguration instead of secret leakage.
For practitioners
- Inventory every agent secret path Map where Anthropic API keys or equivalent credentials are stored, echoed, or passed into agent runtimes, including environment variables, config files, and shell history.
- Replace reusable keys with federated issuance Move agent authentication to short-lived token exchange so the machine never stores a durable bearer secret that can be copied and replayed.
- Scope federation rules per audience Bind each agent trust relationship to the exact relying party and approved subject pattern, then reject any audience that is not explicitly allowed.
- Test replay resistance under live conditions Attempt a second exchange with the same assertion and verify that the platform and relying party reject reuse after first presentation.
Key takeaways
- Agent identity risk is no longer just about secret storage, because federated token exchange moves the control point to trust policy and token lifetime.
- The article's replay behaviour shows why single-use assertions matter: once the token has been presented, a copied copy should not remain viable.
- Audience scoping is now an identity governance control, not a protocol footnote, because it limits where a valid agent token can be used.
Related NHI Mgmt Group resources: NHI Authentication Guide · Guide to the Secret Sprawl Challenge · API Key Management Guide · Agentic AI Identity Guide
Key terms
- Workload Identity Federation: A mechanism allowing workloads in one environment to authenticate to another using short-lived tokens rather than stored credentials, based on mutual trust between identity providers.
- Audience Allowlist: An audience allowlist is the set of relying parties a trusted issuer is permitted to mint tokens for. It prevents a valid token from being reused against an unintended service, making the trust boundary explicit and reducing accidental overreach in federated authentication.
- Single-Use Assertion: A single-use assertion is a token or credential that becomes invalid after first presentation. In agent authentication, this sharply reduces replay value because a copied token cannot be reused to impersonate the workload after the initial exchange completes.
- Identity Blast Radius: The amount of damage a compromised identity can cause across systems, data, and infrastructure. In NHI environments, it is shaped by permissions, network reach, and administrative capability rather than by the credential alone. Reducing blast radius is a containment strategy that limits lateral movement and data exposure.
Deepen your knowledge
NHI governance, agentic AI identity, and machine identity security are core topics in our NHI Foundation Level course, the industry's only accredited NHI security programme. If you are building or maturing an IAM programme, it is worth exploring.
Published by the NHIMG editorial team on October 27, 2026.
NHI Mgmt Group, the independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org