AivexaNewsSearch
AI news for builders and product teamsChecked every hour

Securing AI agent identity with X.509 PKI on AWS

Collected Oct 20, 2026

AWS and Keyfactor's engineering teams published a reference architecture for giving AI agents cryptographic identities using X.509 public key infrastructure, built on Keyfactor's EJBCA Enterprise certificate authority and a set of AWS services. The design is aimed at the gap created by the Model Context Protocol, which defines how LLM-powered agents invoke tools such as database queries or email operations but ships no authentication standard and is deliberately transport-agnostic. Without an identity layer, the post argues, any component could impersonate an agent, replay intercepted credentials or invoke tools without authorization. Complete example source code is offered in an accompanying GitHub repository.

The architecture rests on four mechanisms. Signed request envelopes give proof-of-possession on every agent call; user-signed delegation assertions authorize agents without handing them user credentials; RFC 8693 token exchange produces audience-scoped tokens; and real-time Online Certificate Status Protocol checks push revocations out to all agents at once. These are arranged across three trust boundaries: user to system, agent to agent, and agent to MCP tool server.

In the reference build, a user logs into Keycloak with an OAuth 2.0 password grant and receives a full-session token plus refresh token. The application immediately performs an RFC 8693 exchange to obtain a downscoped token whose audience is restricted to the MCP server, holding the scope database:write, and only that limited token reaches the agents. Separately, the application generates an RSA 2048-bit or stronger key pair locally, submits a CSR to EJBCA's pkcs10enroll REST endpoint, bundles the returned certificate with the locally held private key into a PKCS12 container, and stores it in AWS Secrets Manager. Three agent certificates are issued the same way, one per agent role. The user's private key then signs a delegation assertion: a JSON document listing the SHA-256 fingerprints of all three agent certificates along with the user's subject name, issuance time and expiry. Agents carry that delegation rather than the user's certificate.

When the orchestrator routes work to a sub-agent such as the MySQL or Email agent, it signs the whole payload, including tool name, arguments, a timestamp and a random nonce, using RSA-PSS-SHA256. The receiving agent runs six checks: signature verification, timestamp freshness inside a default 60-second window, nonce uniqueness against a replay cache, certificate chain validation to the trusted CA, a role suffix whitelist, and an OCSP revocation query. Re-sending the same prompt after a transient failure requires a new envelope with a fresh nonce, so even the legitimate sender cannot replay an old one.

The MCP server itself, implemented with FastMCP, applies four checks on every invocation. It introspects the token at Keycloak's /token/introspect endpoint and requires the audience to contain mcp-server, rejecting a full-session token. It re-verifies the envelope. It validates the user's delegation, confirming the calling agent's fingerprint is on the authorized list and the user's certificate is not revoked. Finally it cross-checks that the token username, the delegation subject and the agent certificate's common name prefix all agree, establishing one consistent identity chain from person to tool execution.

Replay defense relies on a 128-bit random hex nonce from Python's secrets module, held in a thread-safe in-memory cache until twice the freshness window has passed. The post lists the attack scenarios this covers: replayed recordings, delayed delivery of intercepted envelopes, stale requests cached by a proxy, and precomputed forgery, since future nonces cannot be predicted.

Key generation happens entirely client-side throughout. EJBCA validates the CSR, applies a certificate profile with 7-day validity and key usage constraints, signs with the CA key and returns the certificate; it never sees private keys. Rotation is a re-enrollment with a new CSR at next login. Storing PKCS12 bundles in Secrets Manager adds a layer because the container password is held separately.

Logout triggers a revocation cascade: the user certificate is revoked in EJBCA, which immediately invalidates every outstanding delegation because delegation checks hit OCSP; all three agent certificates are revoked; secrets are deleted with ForceDeleteWithoutRecovery; and the Keycloak session is terminated, invalidating the downscoped token. Revoking one certificate at the PKI layer removes downstream agent authority without chasing individual tokens or contacting each agent.

The design is deliberately fail-closed: an unreachable OCSP responder, a bad signature, an expired timestamp, a seen nonce or a wrong audience each produce an immediate denial with no graceful degradation. A role map restricts calls so only the orchestrator can reach the MySQL and Email agents; sub-agents cannot call each other or upward. AWS recommends pairing this with Amazon Bedrock Guardrails for content filtering, topic avoidance and grounding checks on responses.

Prerequisites are specific: Keycloak 26.2 or later, since earlier versions use a legacy token exchange incompatible with RFC 8693; EJBCA Enterprise with REST API V1 and a configured OCSP responder; an api-admin.p12 administrator certificate; Python 3.9+; and access to Amazon Bedrock, Amazon RDS for MySQL, Amazon SES and Secrets Manager. Keyfactor says its platform serves more than 1,500 enterprise customers. The pattern generalizes beyond the database example to any MCP-compatible tool server.

A likely trade-off is operational weight. Running a CA, an identity provider, OCSP infrastructure and an introspection endpoint is far more machinery than most teams bolt onto an agent demo, and a synchronous OCSP check on every tool call adds latency and a hard dependency on the responder's availability. The 60-second freshness window is another consideration: very long-running tool calls will need envelope renewal partway through. This suggests the approach suits regulated or high-privilege environments where auditability and rapid revocation outweigh that cost.

Why it matters: Teams building multi-agent systems on MCP currently improvise identity with shared API keys or forwarded OAuth tokens, and this architecture gives them a concrete, revocable pattern to copy rather than invent. Developers should expect to own more infrastructure, including a CA and OCSP responder, and to treat certificate enrollment and renewal as part of the agent lifecycle. For product teams, key rotation and instant revocation become design requirements rather than afterthoughts, particularly where agents act on sensitive records. It is a reference architecture rather than a managed AWS service, so the integration and its operational burden remain the adopter's responsibility.

Read at AWS Machine Learning Blog

Based on reporting from the original publisher. Visit the source for full context and later updates.

Publisher excerpt

Learn how to secure multi-agent AI systems with cryptographic identity using Keyfactor EJBCA and AWS services. This reference architecture combines signed request envelopes, user-signed delegation assertions, RFC 8693 audience-scoped tokens, and real-time OCSP revocation to prove agent identity and prevent request forgery across agent-to-agent and MCP tool calls.