Home / Chapter 6 · Quality and security
Last edited · 11 min read
Agent identity
Services an agent calls need to know who sent each request. A shared API key can’t tell them: anyone can copy it and use it for months. SPIFFE is an open standard that lets you replace it with a short-lived credential, issued automatically based on where and how the process runs.
In plain wordsInstead of a shared door password, a receptionist issues a named pass for one hour. They recognise you, so you don’t need to remember a secret. A lost pass soon expires. The receptionist doesn’t check what you do inside.
Why agents need SPIFFE
- Shared keys. An API key works like a password: knowing it is enough. If every agent replica and two other teams share a key, the log only shows “key X”. Changing it affects everyone, so it gets postponed and the key works for months.
- Leak risk. Content an agent reads can influence its behaviour, so one shell command may expose a key in an environment variable (see “Prompt injection”). An agent calling many systems may hold several such keys.
- First secret. A secrets manager must authenticate the process too, with another secret or an identity from the platform. That’s the “secret zero” problem: where the first credential comes from.
- SPIFFE credentials. A process starts without a secret and asks a local service for a credential. The service identifies it using system data. In SPIRE the credential lasts an hour or 5 minutes by default, and the process fetches a replacement before it expires.
- What you gain. The application’s configuration contains no long-lived secret, and a stolen credential expires quickly. Each agent role can have its own identity for logging and policy, so you can block one role without affecting the others.
- What about a plain OAuth token? A short-lived access token works much like a JWT-SVID. The matrix shows OAuth with a
client_secretin.env. An agent with no shell or file access can’t take it out itself, but such a secret can leak from a repository, container image or backup. OAuth workload identity federation and IAM roles in one cloud can also remove the long-lived secret. SPIFFE gives you the same with one model across environments. - Limits. SPIFFE identifies the caller but doesn’t decide whether a call is allowed. A manipulated agent has a genuine identity, and a compromised process can fetch new credentials. You need narrow permissions, isolation and human approval.
Three ways to authenticate an agent: what the attacker is left with
An agent handles support tickets and uses a CRM. Rows are situations, columns are ways to authenticate, and cells show what the attacker holds. Tap a cell, and the next steps explain each column.
- Attacker holds
- Access time
- Reach
Default TTLs in SPIRE: 1 h for a certificate, 5 min for a token. Both can be shortened.
How SPIFFE works
Step from a SPIRE entry to the MCP server’s decision. Highlights show who is communicating at each step
Messages are shortened; names and values are examples. This combines existing standards for services in your own trust domain. It isn’t a ready-made profile: MCP doesn’t specify mTLS or SPIFFE, and your authorization server must support certificate-bound tokens.
- SPIFFE is an open standard; SPIRE is its most widely used implementation. A SPIFFE ID, such as
spiffe://acme.example/agent/support, names an identity in the trust domainacme.example, under a common issuing authority. An SVID is a signed credential for that ID: an X.509 certificate or JWT. A process fetches it through the local Workload API socket. The domain’s public keys form a bundle used to verify SVIDs. Below, “SPIRE agent” means the service on a node and “agent” means the AI agent. - The SPIRE server acts as the certificate authority (CA) and signs SVIDs. It holds the signing keys and registration entries: rules specifying which processes on which nodes receive each ID.
- The SPIRE agent runs on every node. It identifies the caller at the socket and issues only that process’s SVIDs. It holds SVIDs and keys for processes on the node.
- The agent process holds its certificate, private key and bundle. On each connection it proves it has the key and checks the other side.
- The authorization server verifies the agent’s SVID and the user’s consent, then issues a token signed with its own key. The MCP server has its own SVID and bundle. It checks the certificate, token and access policy before deciding.
- Node attestation. Before a SPIRE agent issues anything, the server must trust it. The SPIRE agent verifies the server using a bundle from the operator. In Kubernetes it presents a signed service account token, which the server checks through the TokenReview API. The SPIRE agent receives its own SVID and connects to the server over mTLS. It receives only entries for its node or group. This moves secret zero from the application to platform configuration.
- Workload attestation. The Workload API deliberately doesn’t authenticate clients directly. The SPIRE agent gets the caller’s PID from the kernel, identifies its pod via cgroup, and gets selectors from the kubelet, such as
k8s:ns:prodandk8s:sa:support-agent. All entry selectors must match or the process receivesPermissionDenied. - Keys. The SPIRE agent creates the process’s key pair and sends only a CSR, a public key with a signing request, to the server. The server signs the certificate with the CA’s key and doesn’t receive the process’s private key. The certificate stays cached until the process fetches it; the SPIRE server isn’t involved in tool calls. A JWT-SVID has no process key pair: the server signs it with a separate JWT key.
- Renewal. The SPIRE agent usually renews a certificate halfway through its validity and sends it over an open stream. The application must reload it. If it reads the certificate only at startup, it stops working when the certificate expires.
- MCP and authorization servers in the same trust domain fetch the bundle through their own Workload API and receive new keys over the same stream. Servers outside the domain lack that socket, so domains exchange bundles (federation) or an operator configures them manually. Tools without SPIFFE support use only the OAuth token.
- How trust is established. The kernel supplies a PID the process can’t forge, and the kubelet identifies the pod. The server has verified the node. The SPIRE agent issues only identities assigned to that node and matching the selectors. The CA’s signature lets the receiver verify a certificate using the bundle, without contacting the SPIRE server. The TLS handshake proves possession of the private key. The certificate is public and proves nothing on its own, so protect the key. The receiver must also check the expected SPIFFE ID: a valid signature confirms only the domain.
Agent and user identity
- A SPIFFE ID identifies the agent, but not the user it works for. Without that information, a broadly privileged agent can become a “confused deputy”: a user obtains data they can’t access through an agent that can. Access decisions must account for both identities and allow only what both the agent and user may do.
- RFC 8693 distinguishes impersonation from delegation. With impersonation, the token recipient treats A as B. With delegation, A keeps its identity in the token’s
actclaim. Agents need delegation so an audit can distinguish a human click from a model’s decision. In the authorization code flow above,client_ididentifies the agent;actusually appears with token exchange. - The agent shouldn’t know the user’s password or hold their long-lived token. It gets a token for one server and scope, and authenticates to the authorization server with its SVID.
- A tool calling another service exchanges the token for a new, narrower one. MCP forbids forwarding it (token passthrough).
Limits and uses
- mTLS prevents eavesdropping, certificate use without its key, and impersonation if you check the expected SPIFFE ID. It won’t stop key theft or code with socket access.
- TTL limits stolen credential use. It won’t stop an attack in progress or a process fetching replacements via the socket.
- Checking
audprevents token use at another service. The token can still be replayed at the same service. - Checking
cnfblocks use of a logged token without its private key. Stealing both bypasses this protection. - Node attestation blocks a service posing as a SPIRE agent. Workload attestation rejects processes without matching selectors, but admits any with the same selectors.
- The tool’s policy blocks calls outside the role and limits, but allows harmful calls that meet its rules. Of these checks, only policy constrains a manipulated agent, whose SVID is valid. Narrow permissions and human approval also help.
- An entry based on namespace and service account can’t distinguish a harness from a shell it starts: both processes have the same selectors, and the caller chooses
audinFetchJWTSVID. If the model can run commands in a container with the Workload API socket, it can obtain the agent’s identity and a token for any service that accepts it. Executable path or hash selectors narrow the entry, but separating containers is simpler: keep the socket with the harness and run tool code in a separate sandbox with different selectors (see “The coding-agent harness”). - Blocking an agent takes time. Deleting its registration entry stops new SVIDs, but existing ones work until expiry, and the SPIRE agent may briefly use cached entries. Lifetimes add up: a 5-minute JWT-SVID exchanged just before expiry for a 15-minute AWS session gives almost 20 minutes of access. An open TLS connection also lasts until the server limits it. Set TTLs for the longest combined access time across the chain.
- Replicas usually share an ID because they have the same selectors. A role ID and session number are enough for logs. An instance ID requires an entry for each pod.
- Selectors are trustworthy only for unprivileged processes: SPIRE’s documentation says root on a node can change cgroup membership. A compromised node exposes identities allowed there by registration entries, including those shared with other nodes. If any can obtain an intermediate CA or manage the SPIRE server, the whole domain is at risk. Compromising the SPIRE server also endangers the whole domain.
- In one cloud, start with its native workload identity, such as IAM roles for pods. These provide short-lived credentials without extra infrastructure. SPIFFE pays off when agents and tools span several clouds or clusters, or different systems need a shared identity model.
- SPIRE is a critical service: an outage blocks issuing and renewing SVIDs, and short TTLs leave little repair time. A laptop coding agent runs under your account, so attestation adds little. A sandbox and narrowly scoped tokens matter most.
- As of October 2026, SPIFFE is used in production, but standards for agents are still emerging. AIMS, an informational draft from the IETF’s WIMSE working group, combines existing standards. It defines no protocol or MCP profile.
Check yourself
How should an agent prove its identity to tools, and what doesn’t SPIFFE solve?
An API key proves only that someone holds it, so an agent should get a short-lived credential instead. In SPIFFE, a process fetches an SVID, a certificate or JWT with a SPIFFE ID, through the local Workload API. It supplies no secret: the SPIRE agent, already verified by the server, identifies it through the kernel and orchestrator. The SPIRE server signs the certificate; the receiver verifies it using the bundle. The certificate enables mTLS, and a certificate-bound token requires the private key. The tool’s access decision must account for both agent and user. SPIFFE doesn’t judge intent: a manipulated agent has a valid SVID, and a shell in its container can usually obtain the same identities. You still need a sandbox, narrow permissions and human approval.
Po polsku
Klucz API potwierdza tylko, że ktoś go ma, dlatego agent powinien dostawać krótkotrwałe poświadczenie. W SPIFFE proces pobiera z lokalnego Workload API SVID, czyli certyfikat albo JWT z SPIFFE ID. Nie podaje przy tym żadnego sekretu, bo agent SPIRE, sprawdzony wcześniej przez serwer, rozpoznaje go przez jądro i orkiestrator. Serwer SPIRE podpisuje certyfikat, a odbiorca sprawdza go zestawem kluczy. Certyfikat daje mTLS, a powiązany z nim token nie zadziała bez klucza prywatnego. Decyzja w narzędziu musi uwzględniać agenta i użytkownika. SPIFFE nie ocenia intencji: zmanipulowany agent ma ważny SVID, a powłoka w jego kontenerze zwykle dostanie te same tożsamości, więc nadal potrzebne są piaskownica, wąskie uprawnienia i zatwierdzanie przez człowieka.
Follow-up questions (5)
- Does SPIFFE protect against prompt injection?
- Partly. Credentials expire quickly, and the harness keeps them outside the model’s context. This won’t stop a manipulated agent using its own valid permissions to call tools (see “Prompt injection”). Narrow permissions, policy in the tool and human approval help.
- JWT-SVID or X.509-SVID?
- Use X.509-SVID for a direct TLS connection to the service: mTLS proves possession of the key. Use JWT-SVID with a proxy that terminates TLS. It’s a bearer token, so set one aud and a short lifetime. WIMSE Proof Tokens and HTTP signatures prove key possession at the application layer.
- Why separate tools from the harness?
- Attestation sees a process and container, not who issued a command. With namespace and service-account selectors, a shell in the harness’s container matches the same entry. The Workload API issues it the same SVIDs for any aud. A separate sandbox without the socket and with different selectors blocks this path.
- How fast can you block an agent?
- Deleting the registration entry stops new SVIDs; existing ones work until expiry. Cached entries, open TLS connections and credentials exchanged for cloud tokens also affect access time. Lifetimes add up: an exchange just before expiry starts a new session. Set TTLs and connection limits for that worst-case total.
- When is SPIFFE overkill?
- When an agent runs in one cloud and native roles suffice. Also on a laptop, where the agent runs under the user’s account and attestation adds little. SPIRE is another critical service, so it pays off across several clouds, clusters or teams.