Securing AI Agents: Identity and Authorization for Autonomous Systems

· Michael Chen · 12 min read

Autonomous AI agents are reshaping how organizations interact with APIs, databases, and infrastructure. An AI agent processes natural language instructions, decomposes them into API calls, retrieves context from knowledge bases, and executes multi-step workflows without human intervention at each step. This autonomy creates a fundamental security challenge: traditional authentication and authorization systems were designed for humans who make deliberate, one-at-a-time decisions, not for software agents that execute hundreds of API calls per minute across multiple services. The security architecture for AI agent traffic requires new patterns for identity, delegation, credential isolation, and access control that differ substantially from human user security. This guide covers the infrastructure patterns that secure AI agents at the edge, the origin, and every service boundary in between.

How Does AI Agent Identity Differ from Human Identity?

AI agent identity represents a new category in identity management that sits between human user identity and service account identity. A human user authenticates through interactive flows (OAuth 2.0 authorization code, passkeys, SAML) and makes intentional decisions about each action. A service account authenticates with static credentials (API keys, client certificates) and performs predetermined operations. An AI agent combines characteristics of both: it acts with derived authority from a human user, but executes autonomously like a service account, making real-time decisions about which APIs to call and which data to access.

The delegation chain is the critical concept for AI agent identity. When a user instructs an AI agent to "summarize last quarter's sales data and email the report to the leadership team," the agent must access the sales database, generate a summary, and send emails. Each of these actions requires authorization. The agent does not have its own inherent right to access sales data or send emails. The agent operates under delegated authority from the user who initiated the instruction. This delegation must be cryptographically verifiable at every service boundary.

OAuth 2.0 Token Exchange (RFC 8693) provides the mechanism for encoding delegation chains. The user's original access token is exchanged for an agent-scoped token that carries an act (actor) claim identifying the agent alongside the sub (subject) claim identifying the delegating user. Every service that receives this token can verify both who authorized the action (the user) and what is performing the action (the agent).

# Agent token payload with delegation chain
{
  "sub": "user-7291",           # Delegating user
  "act": {
    "sub": "agent-sales-bot-03", # Acting agent
    "agent_type": "retrieval",
    "deployment": "prod-us-east"
  },
  "aud": "sales-api.internal",
  "scope": "sales:read reports:write",
  "exp": 1727741700,            # 15-minute lifetime
  "iat": 1727740800,
  "jti": "txn-a8f3e2d1",
  "intent": "quarterly-summary"  # Intent-based scope
}
AI Agent Delegation Chain: User to Agent to Services AI Agent Delegation Chain Human User OAuth 2.0 login sub: user-7291 Auth Server Token Exchange RFC 8693 STS AI Agent act: agent-bot-03 Delegated token User token Agent token CDN Edge Validate + rate limit Agent-aware WAF Sales API scope: sales:read Vector DB RAG retrieval Email Service scope: email:send Each service verifies: act claim (agent ID) + sub claim (delegating user) + scope match
Figure 1: AI agent delegation chain from user authentication through token exchange to service-level authorization

Token Vault Architecture: Credential Isolation for AI Agents

The most dangerous pattern in AI agent deployment is giving agents direct access to credentials. An AI agent that holds an API key, database password, or OAuth token in memory becomes a high-value target. If the agent is compromised through prompt injection, memory exploitation, or supply chain attacks on its dependencies, the attacker gains reusable credentials that work independently of the agent. The Token Vault pattern eliminates this risk by ensuring agents never touch raw credentials.

Performance Comparison: Edge vs Origin Processing
Metric Edge Processing Origin Processing Improvement
Latency (p50)8–15 ms120–300 ms15–20x faster
Cache Hit Ratio85–95%N/AReduces origin load
TLS Handshake1–5 ms (nearby PoP)50–150 ms10–30x faster
Bandwidth Cost$0.01–0.04/GB$0.05–0.12/GB3–5x cheaper
Availability99.99% (multi-PoP)99.9% (single DC)10x fewer outages

A Token Vault is a credential proxy service that sits between the AI agent and external APIs. The agent does not request credentials from the vault. Instead, the agent submits a structured action request: the target API, the HTTP method, the endpoint path, and the request body. The Token Vault performs four operations before executing the request:

The vault stores credentials in hardware security modules (HSMs) or encrypted key management services, never in application memory. Credential access policies define which agent types can use which credentials, under what conditions, and with what rate limits. A retrieval agent might have read-only access to the sales API limited to 100 requests per minute, while an automation agent might have read-write access to the CRM limited to 10 mutations per minute.

# Token Vault action request (agent never sees credentials)
POST /vault/execute
Authorization: Bearer {agent-delegation-token}

{
  "target": "sales-api.internal",
  "method": "GET",
  "path": "/v2/reports/quarterly?period=2026-Q3",
  "headers": {
    "Accept": "application/json"
  },
  "intent": "quarterly-summary",
  "max_response_size": "10MB"
}

# Vault internally:
# 1. Validates agent token (act + sub + scope)
# 2. Checks policy: agent-sales-bot-03 can GET /v2/reports/*
# 3. Retrieves API key from HSM
# 4. Injects: Authorization: ApiKey sk_live_...
# 5. Forwards request, returns response to agent
# 6. Logs: {agent, action, target, status, latency}
Token Vault Architecture: Credential Isolation for AI Agents Token Vault: Credential Isolation Architecture AI Agent Holds: delegation token NO raw credentials Token Vault 1. Validate agent token 2. Check action policy 3. Inject credential from HSM 4. Forward + audit log External APIs Databases HSM / KMS Encrypted credentials Audit Log (immutable) Action request +Credential Trust boundary: credentials never leave this perimeter
Figure 2: Token Vault architecture ensuring AI agents never possess raw credentials, with HSM-backed storage and immutable audit logging

Intent-Based Access Control for AI Agents

Traditional role-based access control (RBAC) assigns broad permissions: "read access to the sales database." For a human user making deliberate queries, this is acceptable. For an AI agent executing autonomous multi-step workflows, broad permissions create unacceptable risk. An agent with "read access to the sales database" could read every customer record, every transaction, and every internal note, then surface that information in responses to any user who interacts with the agent.

Intent-based access control narrows permissions to the specific operation the agent is authorized to perform. Instead of granting database-level read access, intent-based policies grant permission to execute specific, parameterized queries. The agent's delegation token includes an intent claim that identifies the authorized operation. The WAF layer or API gateway validates that the agent's actual requests match the declared intent.

Intent-based scoping works at three levels:

The edge function layer enforces operation scope by matching the request path and method against the token's allowed operations. The origin API enforces data scope by applying row-level security filters based on the delegation claims. Output scope requires application-level controls in the agent framework itself, validating that the agent's planned actions (send email, write file, call API) are within the permitted output set.

RAG Authorization: Controlling Knowledge Access

Retrieval-Augmented Generation (RAG) introduces a unique authorization challenge. When an AI agent queries a vector database to retrieve context for generating responses, the retrieval operation must respect the access control boundaries of the underlying documents. A sales agent retrieving quarterly data should not inadvertently access HR documents, legal correspondence, or executive strategy memos that happen to be semantically similar to the query.

RAG authorization operates at the embedding retrieval layer, not the generation layer. Every document chunk stored in the vector database carries access control metadata: tenant ID, department, classification level, and authorized roles. When the agent issues a similarity search query, the vector database applies access control filters before returning results. The agent only receives chunks that the delegating user is authorized to access.

# RAG query with authorization filters
{
  "query_vector": [0.12, -0.34, 0.56, ...],
  "top_k": 10,
  "filter": {
    "tenant_id": {"$eq": "tenant-123"},
    "classification": {"$in": ["public", "internal"]},
    "department": {"$in": ["sales", "marketing"]},
    "authorized_roles": {"$contains": "sales-analyst"}
  },
  "namespace": "documents-prod"
}

The authorization filters must be injected by the infrastructure layer, not by the agent itself. An agent that constructs its own filter queries can be manipulated through prompt injection to remove or weaken filters. The Token Vault or API gateway should translate the agent's delegation token claims into filter parameters and inject them into every vector database query before the query reaches the database. The agent's query specifies the semantic intent; the infrastructure enforces the access boundary.

CDN Edge Enforcement for AI Agent Traffic

AI agent traffic differs from human user traffic in ways that demand specialized handling at the CDN edge layer. Human traffic follows browsing patterns: page loads, asset fetches, form submissions with seconds or minutes between interactions. Agent traffic follows API patterns: rapid sequential API calls, large response bodies, sustained throughput over minutes or hours, and no asset fetches. The rate limiting and bot management rules designed for human traffic will either block legitimate agent activity or fail to constrain abusive agent behavior.

Agent-aware rate limiting

Edge rate limiting for AI agents should operate on three dimensions: requests per minute per agent identity, total data transfer per agent per hour, and concurrent request count. A retrieval agent might be permitted 200 requests per minute but limited to 50 MB of total response data per hour and 5 concurrent in-flight requests. These limits prevent a compromised agent from exfiltrating large datasets through rapid, parallel API calls while allowing normal operational patterns.

Traffic routing and isolation

Agent traffic should route through dedicated origin pools separate from human user traffic. This isolation prevents an agent workload spike from degrading human user experience and allows independent scaling, monitoring, and incident response for agent traffic. The edge server identifies agent traffic by the presence of the act claim in the JWT or by a dedicated User-Agent prefix (e.g., AgentBot/1.0 org-id/tenant-123) and routes accordingly.

Payload inspection

Edge WAF rules for agent traffic should inspect both request and response payloads for policy violations. Request inspection catches prompt injection attempts embedded in API parameters. Response inspection catches data exfiltration patterns where an agent requests seemingly innocuous endpoints but the combined responses reveal sensitive information. Pattern-matching rules at the edge can detect and block responses that contain credit card numbers, social security numbers, or other PII that the agent's declared intent does not justify accessing.

Traffic characteristicHuman usersAI agentsEdge enforcement
Request frequency1-5 req/min50-500 req/minPer-identity rate limits
Session durationMinutesHours (continuous)Token TTL enforcement
Response consumptionRendered in browserParsed and re-queriedData volume caps
Error handlingUser retries manuallyAutomated retry loopsBackoff enforcement
AuthenticationSession cookiesBearer tokens + act claimsDelegation chain validation
CacheabilityHigh (static assets)Low (API responses)Separate cache policies

MCP Security Model and Transport Safety

The Model Context Protocol (MCP) provides a standardized way for AI agents to discover and invoke tools, retrieve resources, and interact with services. MCP's shift from Server-Sent Events to Streamable HTTP transport brings security implications for edge infrastructure. Each MCP session carries a session ID (MCP-Session-Id header) that binds a sequence of requests to a single agent interaction context. Edge servers must treat this session ID as security-sensitive: it should not be cached in shared cache keys, should not appear in access logs without masking, and should be validated for format and length to prevent injection attacks.

MCP tool invocations should pass through the same Token Vault pattern described above. When an AI agent calls an MCP tool that accesses an external API, the tool server should not hold credentials directly. Instead, the tool server delegates credential injection to the vault, which validates the agent's delegation token, checks the tool-specific authorization policy, injects the credential, and logs the invocation. This ensures that even a compromised MCP tool server cannot leak credentials.

Edge security headers for MCP traffic should include strict Content-Security-Policy for any rendered responses, X-Content-Type-Options to prevent MIME sniffing of tool responses, and cache-control headers that prevent MCP session state from being cached at intermediate proxies. The zero-trust model applies to MCP traffic just as it does to any other agent communication: every tool invocation is independently authenticated and authorized, regardless of whether previous invocations in the same session succeeded.

MCP Security: Edge Enforcement for AI Agent Tool Invocations MCP Security at CDN Edge AI Agent MCP Client CDN Edge Session ID validation Token + act claim check Agent rate limiting Token Vault Policy check Credential inject Audit log Tool Server A Tool Server B MCP req Edge Security Checklist for AI Agent Traffic 1. Validate MCP-Session-Id format (reject oversized or malformed values) 2. Verify delegation token: signature, exp, aud, act claim present 3. Apply agent-specific rate limits (higher req/min, lower data volume caps) 4. Route to dedicated agent origin pool (isolated from human user traffic) 5. Strip MCP-Session-Id from cache keys and mask in access logs
Figure 3: MCP security enforcement at CDN edge with Token Vault integration for tool invocations

Monitoring and Observability for AI Agent Traffic

AI agent traffic requires dedicated monitoring dashboards that track metrics human traffic monitoring ignores. Agent-specific metrics include: delegation chain depth (how many levels of agent-to-agent delegation exist), intent drift detection (agent requests deviating from declared intent), credential usage patterns (which vault credentials are accessed, how often, by which agents), and RAG retrieval scope (are agents retrieving documents outside expected departments or classification levels).

Alert thresholds for AI agent traffic should be calibrated differently from human traffic. A human user making 100 API calls in a minute is anomalous. An AI agent making 100 API calls in a minute is normal. The anomaly signal for agents is not volume but pattern: an agent that normally queries the sales API suddenly querying the HR API, an agent that normally retrieves 10 documents per query suddenly retrieving 1000, or an agent whose token contains an act chain deeper than the configured maximum delegation depth.

Audit logs for agent activity should capture the full delegation chain (who authorized the agent, which agent instance, which tool was invoked), the intent claim from the token, the actual API calls made (target, method, path, response status), and the data volume transferred. These logs feed into compliance reporting that demonstrates the organization maintained control over agent access to sensitive data, a requirement under GDPR, HIPAA, SOC 2, and emerging AI governance regulations.

Securing AI agents is not an extension of traditional API security with minor adjustments. Agent autonomy, delegation chains, credential sensitivity, and RAG knowledge access create fundamentally new attack surfaces that demand purpose-built infrastructure patterns. The Token Vault, intent-based access control, RAG authorization filters, and edge-layer enforcement described in this guide form a defense-in-depth architecture that constrains AI agents to their authorized scope while preserving the operational speed that makes agents valuable. As AI agent deployment scales from experimental to production-critical, these security patterns will become as fundamental as TLS and WAF are today.

External References

References & Standards: Cloudflare documentation · W3C Web Performance