TL;DR: AI agents are still commonly authenticated with hardcoded API keys in environment variables, leaving credentials exposed to prompt injection and runtime compromise, while only 10% of organisations have a well-developed strategy for managing non-human and agentic identities, according to Okta survey data. Static secrets are the wrong trust model for autonomous software that selects tools and calls APIs at runtime.
At a glance
What this is: This article argues that AI agents are being built on static API keys and environment variables, creating a credential exposure problem that scales with agent autonomy and multi-provider use.
Why it matters: IAM and identity teams need to treat AI agents as operational identities, because static secret patterns do not survive prompt injection, runtime scope drift, or per-request access decisions.
By the numbers:
- Only 10% of organizations have a well-developed strategy for managing non-human and agentic identities.
👉 Read Aembit's analysis of AI agent identity risk and workload identity controls
Context
AI agent identity is the problem here, not just credential hygiene. The article shows that teams are extending human-era authentication patterns, especially static API keys, into software that can make independent tool calls across multiple providers at runtime.
That mismatch creates an identity governance gap for NHI programmes. When an agent can be prompted to reveal its own environment variables, the credential is no longer just a secret management issue, it becomes an access-control failure tied to the agent’s runtime behaviour.
Key questions
Q: How should security teams authenticate AI agents without hardcoded keys?
A: Use workload identity, cryptographic attestation, and short-lived token issuance so the agent proves where it is running instead of presenting a reusable bearer secret. The goal is to keep credentials out of the agent process entirely. That reduces disclosure risk, limits blast radius, and aligns authentication with runtime context rather than static possession.
Q: Why do AI agents make static API keys a worse risk than in normal applications?
A: Because agents can be manipulated through conversation, and the same interface used for legitimate work can be used to coax them into exposing credentials or headers. A normal application does not reason about prompts or respond to social engineering in the same way. Once the secret is reachable through the agent, bearer-token compromise becomes much easier.
Q: What do teams get wrong about prompt injection and identity controls?
A: They treat prompt injection as a content problem instead of an access problem. The real issue is whether the agent can ever see or disclose usable secrets. If the credential lives in the agent’s memory, configuration, or environment, the attacker only needs to persuade the system to reveal it. Identity design has to remove that exposure path.
Q: What should organisations do when an AI agent needs multiple LLM providers?
A: They should centralise credential issuance and mediate per-provider access rather than embedding a separate long-lived key for each endpoint. Multi-provider stacks multiply the number of bearer secrets and expand blast radius when one is exposed. A common identity layer keeps the agent code simpler and makes runtime authorisation easier to control.
Technical breakdown
Why static API keys fail for AI agent identity
Static API keys are bearer tokens, which means possession is the only proof of access. That model works poorly for AI agents because the agent’s runtime context changes, its provider mix changes, and its exposure surface includes conversation itself. The article describes a common anti-pattern: keys stored in environment variables, then reused across long-lived agent processes. Once an attacker can influence the agent through prompt injection, the credential can be surfaced or misused without breaking cryptography. The problem is structural, not just operational.
Practical implication: move AI agents away from persistent bearer tokens and treat credential possession as an unacceptable standing privilege.
Prompt injection as a credential theft path
Prompt injection turns natural language into an attack channel against identity controls. Instead of exploiting code directly, an attacker can coerce an agent into printing configuration, exposing headers, or making outbound calls that leak authentication material. That is distinct from traditional web application compromise because the agent itself is the intermediary that reveals the secret. The article also notes that multi-provider workflows widen the risk, since each provider’s auth pattern differs and developers often standardise on the easiest shared secret approach. That makes one compromised conversation enough to expose multiple service credentials.
Practical implication: assume conversational input can trigger credential disclosure and separate agent reasoning from any access to secrets.
Workload identity and per-request credential injection
The article’s alternative is workload identity backed by cryptographic attestation and short-lived OAuth-based access. In practice, the agent proves where it is running, a policy engine decides whether the request is valid, and the credential is injected only for that call. That changes the trust boundary from stored secret to verified runtime state. It also reduces blast radius because the agent never receives a reusable secret to retain, copy, or reveal. For teams running multiple LLM providers, this per-request pattern is the only scalable way to keep authentication aligned with runtime behaviour.
Practical implication: place a credential mediation layer between the agent and the API so the agent never holds the underlying secret.
Threat narrative
Attacker objective: The attacker wants reusable access to the agent’s upstream AI services and any connected systems that trust the exposed token.
- Entry occurs when an attacker targets an AI agent that depends on static API keys stored in environment variables or configuration files.
- Escalation happens when prompt injection convinces the agent to reveal credentials, headers, or runtime configuration, turning the agent into the disclosure channel.
- Impact follows when the exposed bearer token is reused to access LLM services or adjacent systems with the same over-scoped credential.
Breaches seen in the wild
- Moltbook AI agent keys breach — Moltbook breach exposed 1.5M AI agent keys.
- IOS app secrets leakage report — iOS apps leaking hardcoded secrets and credentials endangering user privacy.
Read our 52 NHI Breaches Analysis report for a comprehensive view of breaches impacting Non-Human Identities including AI Agents.
NHI Mgmt Group analysis
Static secrets are the wrong trust primitive for autonomous software. The article shows AI agents being authenticated like long-lived applications, even though they make runtime decisions and can be coerced through conversation. That is a governance failure, not just a deployment mistake, because bearer-token identity assumes the secret can be kept separate from the actor. Practitioners should treat this as an NHI design defect, not a tuning problem.
Prompt injection turns identity into a disclosure surface. When an agent can be persuaded to print its own environment variables, the attacker no longer needs to break the provider. The policy boundary has already failed inside the agent workflow. This is a classic example of identity trust being mediated by the application layer instead of the identity layer, and that distinction matters for OWASP-NHI and zero-trust design.
Identity blast radius is expanding faster than teams are modelling it. Multi-provider agent stacks turn one exposed token into a chain of downstream dependencies, so the compromise is not limited to one call path. Dynamic tool use makes the set of reachable services fluid at runtime, which means static access reviews miss the actual exposure. The practitioner conclusion is straightforward: review agent entitlements as live runtime paths, not as fixed provisioning records.
Workload identity should replace secret possession as the control plane for AI agents. Cryptographic attestation, short-lived tokens, and per-request issuance map much better to machine identity than hardcoded keys do. This aligns with OWASP-NHI and ZT-NIST-207 because trust is evaluated at the point of use rather than assumed at deployment. Teams that keep static keys in place are choosing convenience over a governance model that fits the actor.
Prompt-injection-resistant AI governance requires removing retrievable credentials from the agent entirely. The article’s core failure mode is not that the agent is clever enough to be tricked, but that it is permitted to possess something worth tricking it for. That is the named concept here: retrievable credential debt. Once a secret can be surfaced in conversation, the security model has already collapsed. Practitioners need to recognise that state as a governance red flag, not a local implementation bug.
From our research:
- 64% of valid secrets leaked in 2022 are still valid and exploitable today, according to Guide to the Secret Sprawl Challenge.
- 24,008 unique secrets were exposed in MCP configuration files in 2025 alone, showing how agent infrastructure can create new credential exposure surfaces at scale.
- For a broader governance lens, the Secret Sprawl Challenge explains why secret exposure is a lifecycle problem, not just a detection problem.
What this signals
Retrievable credential debt: once an agent can expose a usable secret in conversation, the identity model has already failed. Teams should assume that prompt injection, debugging prompts, and operational support interactions can all become disclosure channels unless the credential never reaches the agent in the first place.
The operational signal is simple: if your AI platform still depends on static bearer tokens, you are already carrying standing privilege in a runtime that can be socially engineered. That makes workload identity and per-request issuance the right planning baseline for any programme that expects to scale agent deployments safely.
With 24,008 unique secrets exposed in MCP configuration files in 2025 alone, surrounding AI infrastructure is leaking faster than most governance programmes can inventory it. That is why agent authentication and secret governance need to be handled together, not as separate workstreams.
For practitioners
- Eliminate persistent API keys from agent runtime paths Move AI agent authentication away from environment-variable secrets and toward short-lived credentials that are issued per request and never stored in the agent process.
- Insert a credential mediation layer before external calls Ensure the agent can request a service without ever seeing the underlying token, header, or secret material that authorises the call.
- Treat prompt injection as an identity event Add controls that prevent agents from printing configuration, leaking headers, or exposing environment variables when prompted to debug or explain themselves.
- Review agent entitlements as runtime paths Map which services each agent can reach in production, then reduce the number of provider accounts and downstream systems any single credential can touch.
Key takeaways
- AI agent authentication based on static keys creates a standing-privilege problem that prompt injection can convert into direct credential exposure.
- The article shows why bearer tokens and environment variables do not scale to autonomous, multi-provider agent workflows.
- Workload identity, attestation, and short-lived credential issuance are the control patterns that fit AI agents better than persistent secrets do.
Standards & Framework Alignment
This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.
OWASP Non-Human Identity Top 10 address the attack and risk surface, while NIST Zero Trust (SP 800-207) and NIST AI RMF set the governance and control requirements practitioners need to meet.
| Framework | Control / Reference | Relevance |
|---|---|---|
| OWASP Non-Human Identity Top 10 | NHI-01 | Static key storage in agents maps to non-human identity credential exposure. |
| NIST Zero Trust (SP 800-207) | PR.AC-1 | Runtime attestation and contextual authorisation align with zero-trust access decisions. |
| NIST AI RMF | Agentic behaviour requires governance that accounts for runtime decision-making and accountability. |
Define ownership, policy enforcement, and monitoring for agent actions before they are allowed into production.
Key terms
- AI Agent Identity: The identity used by software that can choose actions, tools, and timing at runtime. In practice, it is the control boundary that determines what an agent can access, and whether that access is tied to a reusable secret or to verified runtime state.
- Workload Identity: A machine identity derived from the runtime environment rather than from a shared secret. It allows systems to prove who or what they are through attestation, then receive short-lived access for a specific request or session.
- Prompt Injection: A technique that manipulates an AI system through crafted input so it follows attacker-chosen instructions. In identity terms, it becomes dangerous when the agent can be convinced to reveal secrets, headers, or other access material it should never expose.
- Bearer Token: A credential that grants access to whoever possesses it, without binding that access to the runtime context or the actor’s identity posture. For AI agents, bearer tokens are high risk because exposure of the token is often enough to obtain service access.
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 responsible for identity security strategy or NHI governance in your organisation, it is worth exploring.
This post draws on content published by Aembit: AI agents still depend on static keys, and that breaks. Read the original.
Published by the NHIMG editorial team on 2025-09-09.
NHI Mgmt Group — the independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org