Listen to this Post

Introduction:
The AI agent revolution has introduced an uncomfortable paradox: these autonomous systems are goal-oriented and stochastic, meaning they will willingly hand over credentials if they believe it solves a problem — no malicious prompt injection required. Yet every API call, every MCP server interaction, and every LLM request requires authentication, forcing organizations to choose between functionality and security. The Credential Brokering for AI Agents (CB4A) framework, now an IETF draft, offers a radical solution: stop giving agents credentials altogether and let a broker handle authentication just in time.
Learning Objectives:
- Understand why bearer tokens and long-lived API keys are fundamentally incompatible with AI agent architectures
- Master the three CB4A credential proxy models and determine which fits your enterprise security posture
- Implement credential injection patterns using agentgateway to keep secrets out of agent memory and context windows
- Apply sender-constrained tokens (DPoP) and workload identity (SPIFFE/SPIRE) to make stolen credentials useless
- Design a credential brokering architecture that separates policy decision from credential delivery
You Should Know:
- The Bearer Token Problem: Why AI Agents Cannot Be Trusted with Credentials
The fundamental flaw in traditional authentication is that most credentials are bearer tokens — whoever holds them can use them. This worked for human users with session timeouts and browser isolation, but AI agents are different. They operate autonomously, make stochastic decisions, and their entire context window is readable. When you place an API key in an agent’s environment variable, configuration file, or (worse) its prompt context, you are effectively giving a stochastic system a master key to your infrastructure.
The risk isn’t just prompt injection or exfiltration — agents may hand over credentials willingly. An agent asked “Hey, can you do this for me? Here’s my API key” will comply because it believes it’s solving your problem. This is not malice; it’s the agent’s goal-oriented nature working against you.
The March 2026 TeamPCP supply chain compromise of LiteLLM demonstrated the catastrophic scale of this problem. Attackers injected a credential stealer into PyPI packages, harvesting SSH keys, cloud credentials, LLM API keys, and database passwords from approximately 500,000 corporate identities. LiteLLM’s entire purpose was holding API keys for dozens of providers — making it a high-density credential target.
Solution Options:
- Short-lived credentials — Leaks still happen, but the window of usefulness shrinks to minutes
- Sender-constrained tokens (DPoP) — Holding the bytes isn’t enough; the token is bound to a key
- Don’t give the agent a credential at all — Remove the thing that leaks
The third option is the only complete solution.
- CB4A Three Models: Proxy Gateway, Short-Lived Tokens, and Revocation
The IETF draft from Kenneth G. Hartman specifies three credential proxy models:
Model A — Proxy Gateway (Recommended for Enterprises):
The agent makes its call without any credential. Traffic egresses through a gateway that enforces policy and injects the sensitive bearer credential just in time. The agent never sees, holds, or transmits a real credential. This provides the strongest isolation, full visibility for inspection and logging, and universal compatibility with any target API.
Model B — Short-Lived, Sender-Constrained Tokens:
The broker mints a short-lived, narrowly scoped token and hands it to the agent. This is the draft’s recommended primary approach. However, the agent still holds a real (if temporary) credential in memory — shrinking the window but not closing it. Additionally, DPoP requires both the authorization server and resource server to support it; most SaaS OAuth tokens and GitHub PATs do not.
Model C — Long-Lived with Revocation:
Hand over the real long-lived credential and schedule revocation afterward. The draft calls this the weakest option and does not recommend it.
Why Model A Wins for Enterprises:
Christian Posta argues that for most enterprises today, Model A should be the primary approach, not the fallback. The reasoning: universal compatibility with existing APIs, no credential ever resides in the agent’s memory, and the broker becomes the natural vantage point for behavioral observation and anomaly detection.
3. Implementing Credential Injection with agentgateway
agentgateway implements the CB4A Proxy Gateway model, injecting credentials just in time on egress for MCP and API calls. Here’s how to deploy it:
Step 1: Deploy agentgateway as an Egress Proxy
Install agentgateway via Helm helm repo add solo.io https://storage.googleapis.com/solo-public-helm helm repo update helm install agentgateway solo.io/agentgateway --1amespace agentgateway --create-1amespace
Step 2: Define an AgentgatewayBackend Resource
Create a backend resource for each AI provider or MCP server with per-backend credential injection and authorization:
apiVersion: agentgateway.solo.io/v1 kind: AgentgatewayBackend metadata: name: openai-backend spec: type: OpenAI credentials: secretRef: name: openai-api-key key: api-key auth: type: APIKey headerName: Authorization prefix: Bearer
Step 3: Configure Credential Injection on Egress
The gateway intercepts outbound requests and injects credentials from a centralized vault:
apiVersion: agentgateway.solo.io/v1 kind: EgressPolicy metadata: name: credential-injection-policy spec: match: - backend: openai-backend action: injectCredential: from: vault scope: request-specific
Step 4: Integrate with SPIFFE/SPIRE for Workload Identity
CB4A builds on SPIFFE/SPIRE for workload identity rather than a bespoke identity layer. Configure SPIRE to issue SPIFFE Verifiable Identity Documents (SVIDs) to your agent workloads:
Install SPIRE server and agent helm install spire spire/spire --1amespace spire --create-1amespace Register your agent workload spire-server entry create \ -parentID spiffe://example.org/agent \ -spiffeID spiffe://example.org/workload/agent-gateway \ -selector unix:uid:1000
The agentgateway uses the workload’s SPIFFE ID to determine which credentials it should receive and what policies apply.
4. Sender-Constrained Tokens with DPoP (RFC 9449)
DPoP (Demonstrating Proof of Possession) is an application-level mechanism for sender-constraining OAuth 2.0 tokens. Unlike bearer tokens that any possessor can use, DPoP-bound tokens require the client to prove possession of a private key.
How DPoP Works:
1. The client generates a public/private key pair
- The client sends a DPoP proof JWT signed with the private key alongside the access token request
- The authorization server binds the token to the public key
- The resource server validates the DPoP proof on every request
Implementation Example:
Generate a key pair for the agent openssl genpkey -algorithm RSA -out agent-private.pem -pkeyopt rsa_keygen_bits:2048 openssl rsa -in agent-private.pem -pubout -out agent-public.pem The agent includes a DPoP proof header in each request Header: DPoP: <JWT signed with private key> The JWT contains: - jti: unique ID for this proof - htm: HTTP method - htu: HTTP URI - iat: issued at timestamp
Critical Limitation: DPoP requires both the authorization server and resource server to support it. Most SaaS OAuth tokens, GitHub PATs, and API keys do not check sender constraints, making Model B impractical for many enterprise scenarios.
- The PDP/CDP Separation: Policy Decision vs. Credential Delivery
CB4A’s architectural innovation is separating the Policy Decision Point (PDP) from the Credential Delivery Point (CDP). The component that decides “yes” should never touch credentials, and the component that hands out credentials should never be the one deciding.
Architecture Diagram:
Agent → PDP (Policy Decision) → CDP (Credential Issuance) → Target API ↑ ↑ SPIFFE Identity Vault/Secrets Store User Context Short-lived Token Minting Request Details DPoP Key Binding
Implementation with agentgateway and External PDP:
apiVersion: agentgateway.solo.io/v1 kind: AgentgatewayConfig spec: policyDecision: external: url: https://policy-engine.example.com/decide auth: type: SPIFFE credentialDelivery: vault: address: https://vault.example.com authMethod: jwt role: agent-gateway
The agentgateway can integrate with external policy decision points like Microsoft’s Agent Governance Toolkit (AGT) to govern both LLM traffic and MCP tool traffic.
6. The Vault-as-Target Problem and Behavioral Observation
Credential brokering creates a high-value target: the credential vault. This is the drawback Christian Posta promises to address in Part 2 of his blog series. However, as Marcus House points out, the chokepoint is also the natural seam for behavioral observation.
Why the Broker Is Also the Observation Point:
- The LLM sees only its own calls
- Each downstream API sees only the traffic it received
- The broker sees all of it, per agent, in sequence
This means the broker is positioned to notice a correctly credentialed agent doing something the shape of its own prior behavior says it never does. The issuance record says every call was authorized; the pattern across those calls is where an agent drifting from its task shows up.
Implementing Behavioral Observation:
apiVersion: agentgateway.solo.io/v1 kind: BehavioralPolicy metadata: name: anomaly-detection spec: baselineWindow: 24h detection: - type: rateAnomaly threshold: 3.0 standard deviations - type: scopeAnomaly action: alert - type: sequenceAnomaly action: block
7. Attribution and Audit: Who Called What?
Bernardo Meireles Correa raises a critical operational concern: when credentials are brokered through a gateway, downstream logs show the proxy as the caller, not which specific agent made the request. Attribution becomes a log-correlation exercise on timestamps, which breaks when two agents call in the same second.
Solutions for Attribution:
- Issue a distinct key per agent where the resource allows more than one — the key itself carries the identity
- Make the broker log the system of record and require a request ID the resource echoes back, providing something to join on
- Use ID-JAG (Identity-Justified Agent Gateway) to turn attribution into something the resource can assert instead of something you reconstruct afterwards
Implementation Example:
apiVersion: agentgateway.solo.io/v1 kind: AuditPolicy metadata: name: attribution spec: injectRequestId: true headerName: X-Agent-Request-Id logAgentIdentity: true downstreamEcho: headerName: X-Agent-Id source: spiffeID
What Undercode Say:
- Key Takeaway 1: Bearer tokens are fundamentally incompatible with AI agent architectures. The stochastic, goal-oriented nature of agents means they cannot be trusted with reusable secrets — not because they’re malicious, but because they will comply with requests to hand over credentials if they believe it solves a problem. The only complete solution is to never give the agent a credential at all.
-
Key Takeaway 2: The CB4A Proxy Gateway model (Model A) is the pragmatic choice for most enterprises today. While Model B (short-lived, sender-constrained tokens) is theoretically elegant, it requires both authorization servers and resource servers to support DPoP — a condition most SaaS APIs and legacy systems do not meet. Model A provides universal compatibility, strongest isolation, and transforms the broker into a natural observation point for behavioral anomaly detection.
Analysis: The credential brokering pattern represents a fundamental shift in how we think about authentication for autonomous systems. Traditional IAM assumed human users with bounded sessions and predictable behavior. AI agents are different: they’re autonomous, stochastic, and their entire context is readable. The CB4A framework, now an IETF draft, provides a standardized approach to solving this problem, but enterprises must think carefully about implementation trade-offs. The vault becomes a high-value target, attribution becomes challenging, and the broker’s role as an observation point introduces new possibilities for real-time threat detection. The most successful implementations will likely combine Model A’s proxy gateway with Model B’s sender-constrained tokens where supported, use SPIFFE/SPIRE for workload identity, and build behavioral observation into the broker itself.
Prediction:
- +1 The CB4A framework will become the de facto standard for AI agent authentication within 18-24 months, with major cloud providers and AI platforms building native support for credential brokering patterns
-
+1 agentgateway and similar proxy-based solutions will see rapid enterprise adoption, driven by the pragmatic reality that most APIs do not support DPoP and cannot be retrofitted
-
-1 The concentration of credentials in a broker/vault will create a new class of high-value targets, leading to sophisticated attacks specifically designed to compromise credential brokering infrastructure
-
-1 Attribution challenges will cause significant operational incidents as organizations struggle to determine which agent performed which action, particularly in multi-tenant environments with hundreds of concurrent agents
-
+1 Behavioral observation embedded in the broker will emerge as the primary defense against compromised agents, with machine learning models trained on agent behavior patterns becoming a standard feature of enterprise agent gateways
-
+1 The separation of PDP from CDP will influence broader IAM architecture, with organizations adopting similar patterns for non-AI workloads to reduce the blast radius of credential compromise
-
-1 Organizations that delay adopting credential brokering will experience credential theft incidents as attackers increasingly target AI agent infrastructure, with the LiteLLM compromise serving as a warning of what’s to come
▶️ Related Video (72% Match):
https://www.youtube.com/watch?v=7pqRRxrdr0c
🎯Let’s Practice For Free:
🎓 Live Courses & Certifications:
Join Undercode Academy for Verified Certifications
🚀 Request a Custom Project:
Secure, high-velocity infrastructure and disruptive technological engineering. Contact our engineering team for high-tier development and proprietary systems:
[email protected]
💎 Smart Architecture | 🛡️ Secure by Design | ⭐ Trusted by Thousands
IT/Security Reporter URL:
Reported By: Ceposta Credentials – Hackers Feeds
Extra Hub: Undercode MoN
Basic Verification: Pass ✅


