SPIFFE and SPIRE: workload identity for zero-trust service meshes
Count the credentials in a mid-sized service mesh and the number gets uncomfortable fast: every service that talks to a database, a queue, another service, or a cloud API needs to prove who it is. The traditional answer—a static secret per connection, dropped into an environment variable or a secrets manager—creates a sprawl of long-lived credentials that nobody rotates because rotation means a coordinated redeploy, and that any single leaked container exposes. The secret in a compromised pod is just as valid from the attacker's laptop as from inside your cluster. SPIFFE and SPIRE exist to delete that entire category of problem by giving every workload a short-lived, cryptographically verifiable identity it never has to be handed as a secret.
SPIFFE is the standard; SPIRE is an implementation
It's worth separating the two from the start. SPIFFE (Secure Production Identity Framework For Everyone) is a specification: it defines what a workload identity looks like and how it's carried. SPIRE is the production-grade reference implementation that actually issues those identities. You can adopt the SPIFFE concepts with other tooling, but SPIRE is what most teams run.
The SPIFFE ID
A SPIFFE ID is a URI that names a workload within a trust domain:
spiffe://prod.example.com/ns/payments/sa/invoice-worker
# ^trust domain ^a hierarchical path identifying the workloadIt's stable, human-readable, and platform-agnostic—the same identity model whether the workload runs in Kubernetes, on a VM, or in a serverless function. The path is yours to structure; mirroring namespace and service account is a common convention but not a requirement.
SVIDs: the identity you can actually present
A SPIFFE ID is a name. The thing a workload presents to prove it holds that name is an SVID (SPIFFE Verifiable Identity Document), and it comes in two flavors:
- X.509-SVID — a short-lived X.509 certificate with the SPIFFE ID in the URI SAN. This is what powers mTLS between services: the cert is the identity, verified against the trust bundle.
- JWT-SVID — a signed JWT with the SPIFFE ID as the subject, for cases where you can't do mTLS end to end (crossing an L7 proxy, calling an API that takes a bearer token).
The defining property is that SVIDs are short-lived—certificates measured in hours, often one—and rotated automatically before they expire. A leaked X.509-SVID is useless within hours, and the workload never performs a manual rotation; the SPIRE agent streams fresh ones continuously.
How SPIRE decides who gets what: attestation
The question that makes or breaks any identity system is: how does the issuer know the thing asking for an identity really is who it claims? Handing out identities to anything that asks is just the secrets problem with extra steps. SPIRE answers this with attestation, and it happens at two levels.
Node attestation
First the SPIRE agent on a host proves what node it's running on to the SPIRE server—using a platform signal the agent can't forge, like a cloud instance identity document (AWS/GCP/Azure), a Kubernetes projected service account token, or a TPM. The server now trusts "this agent is on node X."
Workload attestation
Then, when a local process asks the agent for its SVID over a Unix domain socket, the agent inspects the calling process itself—its kernel-reported UID, its container labels, its Kubernetes pod—against registration rules, and only issues the SVID matching what the process actually is. The workload presents no secret and no token; its identity is derived from verifiable properties of the process and its host.
# register a workload: "a pod with this service account on an attested node
# is entitled to this SPIFFE ID"
spire-server entry create \
-spiffeID spiffe://prod.example.com/ns/payments/sa/invoice-worker \
-parentID spiffe://prod.example.com/spire/agent/k8s_psat/prod-cluster/NODE \
-selector k8s:ns:payments \
-selector k8s:sa:invoice-worker \
-ttl 3600The bootstrap problem, solved properly. Every credential system faces the question "how does a brand-new workload get its first credential without already having one?" SPIRE's answer is attestation off platform-native, unforgeable signals—the cloud's own instance identity, the kernel's own view of the process—so the chain of trust roots in the infrastructure, not in a secret someone has to plant. That's the part that's genuinely hard to build yourself.
Consuming an SVID in your code
The SPIFFE Workload API exposes SVIDs over a local socket, and the official libraries handle fetching and hot-rotating them, so your TLS config always uses a current certificate without you writing rotation logic.
import { X509Source, createClientTlsConfig } from "@spiffe/spiffe";
// streams SVIDs from the local agent socket and rotates them automatically
const source = await X509Source.create({ socketPath: "/run/spire/sockets/agent.sock" });
// mTLS that only trusts peers whose SPIFFE ID matches a policy
const tls = createClientTlsConfig(source, {
authorizeId: (id) => id.startsWith("spiffe://prod.example.com/ns/payments/"),
});
// `tls` now carries a cert that silently refreshes before it expires
await callPeerService({ tls });Authorization happens on the verified SPIFFE ID of the peer, not on an IP or a shared secret. "Only the invoice service may call the ledger's write endpoint" becomes a check on the caller's SPIFFE ID—identity-based policy that survives pods being rescheduled onto new nodes with new IPs.
SPIFFE gives you identity, not authorization. An SVID proves who a workload is; it says nothing about what it's allowed to do. Teams sometimes stop at mTLS everywhere and assume they've done zero-trust, but a mesh where every authenticated service can call every other service is flat, not zero-trust. You still need per-call authorization policy keyed on the SPIFFE ID—identity is the foundation it stands on, not a substitute for it.
Where it pays off—and the cost
The payoff is structural: no static service secrets to leak, rotate, or audit; identity that's consistent across clusters and clouds; and a verifiable name for every workload that both mTLS and your authorization layer can key on. The cost is real too—SPIRE is infrastructure you run and must keep highly available (workloads can't get new SVIDs if the server is down), and the attestation and registration model takes genuine effort to set up correctly. For a small service count, it may be more than you need. For a growing mesh drowning in per-service secrets, it's the thing that stops the bleeding.
Workload identity and human identity are the same problem viewed from two angles: proving who's making a request so you can decide what they may do. SPIFFE solves the machine side with short-lived, attested, verifiable identities—exactly the properties you want for users and services alike. Owning your identity layer lets you treat both under one coherent model instead of two disjointed systems; Bastionary speaks SPIFFE JWT-SVIDs alongside user tokens, so a workload and a person are authorized against the same policy engine.
Run it yourself
Bastionary is free, open-source software. Follow the quick start to have it running on your own server, or browse the releases on Git.