Crafting implementation guidelines
I need to create an implementation guide that covers SPIRE server and agents, including registration entries and Envoy SDS. There's also a need to mention external services and gateways. It’s important to cover a revocation strategy too, comparing short-lived credentials versus certificate revocation lists (CRLs). I should include sample policies like role-based access control (RBAC) and authorization policies. The goal is to write a general guide that’s not specific to any one context. Let's dive in!
What “zero-trust TLS everywhere” means (in practice)
Zero trust for service-to-service traffic means you do not trust the network, the subnet, the cluster, or even “inside the mesh.” Every request must be:
- Encrypted (TLS everywhere)
- Strongly authenticated (mutual TLS, i.e., both sides present credentials)
- Explicitly authorized (policy based on workload identity and context, not IPs)
- Continuously validated (short-lived certs, rotation, telemetry, rapid revocation-by-expiry)
A typical implementation uses workload identities (often via SPIFFE IDs) and automated mTLS certificate issuance (often via SPIRE or a mesh CA), with policy enforcement at sidecars/proxies/gateways, plus disciplined rotation runbooks.
1) mTLS issuance: how workloads get certificates (SVIDs)
Key idea
Workloads should not carry long-lived secrets (static client certs). Instead they obtain short-lived X.509 certificates (or JWT-SVIDs) after the platform proves what the workload is.
Components (common pattern)
- Trust Root / CA
- Issues intermediate CAs and/or workload certs
- Can be mesh CA, SPIRE Server, Vault PKI, cloud PCA, etc.
- Workload Attestation
- Proves a workload’s identity based on where/how it runs (Kubernetes SA, node identity, selectors, etc.)
- Issuer / Identity Provider
- Exchanges attestation for a SVID (SPIFFE Verifiable Identity Document): typically an X.509 cert with a SPIFFE ID in SAN
- Delivery to the dataplane
- Sidecar/proxy gets the cert via SDS (Envoy), filesystem, or mesh agent API; reload happens without restart
Flow (typical SPIRE-style)
- Node bootstraps trust: a node/agent gets a node identity (often via cloud instance identity, TPM, Kubernetes node attestation).
- Workload attests: workload (or node agent on its behalf) proves “I am workload X running as SA Y in namespace Z”.
- Identity issued: issuer returns an X.509 SVID (leaf cert) + trust bundle (roots/intermediates).
- mTLS handshake: client and server present certs; each validates:
- signature chain to trust bundle
- validity period
- SAN contains expected identity format (SPIFFE ID)
- Authorization decision happens after authentication, based on identity.
Recommended issuance characteristics
- Short-lived leaf certs: commonly 5–60 minutes (many meshes default ~24h; zero-trust usually pushes shorter if ops allow).
- Automated renewal: renew at ~50–70% of lifetime; maintain overlap.
- No CRLs/OCSP dependency (often): rely on short-lived certs for “revocation-by-expiry” unless you truly need immediate revocation.
2) SPIFFE IDs: the identity layer you authorize on
What is a SPIFFE ID?
A SPIFFE ID is a URI that names a workload, e.g.:
spiffe://example.org/ns/payments/sa/checkout
spiffe://corp.prod/cluster/us-east-1/app/orders
It is typically embedded in the cert’s SAN URI field (not CN). That makes it:
- stable across IP changes
- portable across environments
- explicit (you can reason about it in policy)
SPIFFE/SPIRE roles (quick mapping)
- SPIFFE: the spec for identity format + SVID documents.
- SPIRE: a popular implementation that:
- attests nodes/workloads
- issues X.509 SVIDs / JWT-SVIDs
- distributes trust bundles
Why SPIFFE IDs help “zero trust”
- Replace network-based identity (IP, VPC, subnet) with cryptographic workload identity
- Enable consistent policy across:
- Kubernetes clusters
- VMs
- bare metal
- multi-cloud
3) Policy enforcement: where and how access is actually controlled
Separate the concepts
- Authentication (AuthN): “Who are you?” → proven by mTLS cert / SPIFFE ID
- Authorization (AuthZ): “Are you allowed?” → policy evaluation using that identity (+ method/path, port, claims, etc.)
Where enforcement typically lives
- Sidecar / node proxy (east-west)
- Envoy/Istio, Linkerd, Consul, Cilium, etc.
- Best place for consistent service-to-service enforcement
- Ingress / Egress gateways (north-south and external dependencies)
- Terminate/re-originate TLS
- Enforce policy when talking to outside services
- Service process itself (defense-in-depth)
- App-level authZ for business rules; mesh-level for transport/service authZ
Common enforcement models
A) L4 (TCP) identity-based policy
- Allow SPIFFE IDs to connect to a port
- Useful for non-HTTP protocols
- Example intent: “only
spiffe://…/sa/billing can connect to port 5432 on payments-db”
B) L7 (HTTP/gRPC) policy
- Decisions can include:
- source SPIFFE ID
- HTTP method/path
- gRPC service/method
- request headers (careful—headers are mutable unless set by trusted proxy)
- Example intent: “checkout can
POST /charge, but cannot call admin endpoints”
Policy best practices (zero-trust aligned)
- Default deny between services; explicitly allow required flows
- Authorize by identity, not by IP/CIDR
- Keep policies small and composable
- Use namespaces/tenants in SPIFFE IDs to prevent accidental cross-tenant access
- Enforce egress policy (what a service may call) as strongly as ingress
Audit and telemetry requirements
- Log decisions with:
- source SPIFFE ID
- destination SPIFFE ID/service
- SNI / ALPN / HTTP route
- policy rule that matched
- Track:
- denied connections
- cert issuance/renewal failures
- authZ policy changes (who changed what, when)
4) Certificate rotation: what must rotate, how, and what breaks
What rotates in a TLS-everywhere system
- Workload leaf certs (SVIDs) — frequent
- Intermediate CAs — occasional
- Trust bundle / roots — rare but highest-risk when it goes wrong
- Dataplane configuration (policy updates, trust bundle distribution)
Rotation mechanics (what “good” looks like)
- Hot reload: proxies/apps reload certs without restarting (SDS is ideal)
- Overlap windows:
- Old and new trust anchors coexist during migration
- Leaf cert renewal happens before expiry; both sides can validate throughout
- Time sync is critical: NTP/chrony drift causes “not yet valid/expired” storms
Suggested lifetimes (typical guidance)
- Leaf SVID: 10–60 minutes (or 1–24h if you need a softer ops curve)
- Intermediate: weeks to months
- Root: months to years, but plan for rotation anyway
5) Runbooks (operational playbooks)
Below are practical “do this when…” runbooks that teams actually need.
Runbook A — Workload cert renewal failures (approaching expiry)
Symptoms
- Spike in mTLS handshake failures
- Errors like
certificate expired, no valid SAN, unknown authority
- Proxy metrics show SDS fetch failures / identity agent errors
Immediate containment
- Confirm whether failures are localized (one service/namespace/node) or systemic (cluster-wide).
- If systemic and expiry is imminent: consider temporarily increasing leaf TTL (if your issuer supports it) to stabilize.
Diagnosis checklist
- Identity agent health (SPIRE agent/mesh agent):
- can it reach issuer?
- auth errors?
- Issuer/CA health:
- CA service up, HSM reachable, rate limits
- Node clock skew:
- compare node time vs trusted NTP
- Quotas:
- CA issuance rate limiting
- CPU starvation causing missed renew deadlines
Fix
- Restore agent→issuer connectivity
- Repair time sync
- Restart failed agents (not the whole cluster) if they’re wedged
- Validate renewal resumes and leaf cert expiry horizon increases
Prevention
- Alert on “minimum remaining cert lifetime” per workload/node
- Alert on issuance error rates
- Ensure renew starts at ~50–70% of lifetime
Runbook B — Trust bundle / root rotation (planned)
Goal
Rotate trust anchors without breaking mTLS.
Safe sequence (two-phase, overlap)
- Add new root to trust bundle everywhere (do not remove old yet).
- Wait for propagation + confirmation (all proxies/agents have updated bundle).
- Start issuing leaf certs from new chain (new intermediate under new root).
- Observe handshake success (mixed old/new leaf certs should validate).
- Remove old root only after:
- all workloads have renewed at least once (or you’ve forced re-issuance)
- old intermediates are no longer in use
Validation
- Sample mTLS handshakes from multiple segments
- Confirm both old and new chains validate during overlap
- Monitor auth failures by “unknown authority”
Rollback
- Re-add old root to bundle (fastest rollback lever)
- Revert issuer to old chain if required
Runbook C — CA/intermediate compromise (security incident)
Goal
Minimize blast radius quickly.
Immediate actions
- Stop issuance from compromised CA/intermediate.
- Rotate intermediate (and root if necessary).
- Push updated trust bundles (remove compromised trust where possible).
- Force rapid leaf renewal (shorten TTL, trigger re-issuance).
Reality check
- If clients still trust the compromised root, an attacker can mint certs that validate.
- With short-lived leaf certs, you still must remove trust anchors to fully evict.
Follow-up
- Re-attest nodes/workloads if node identity might be compromised
- Forensic review of issuance logs (who got what identities)
Runbook D — Node compromise / rogue workload
Symptoms
- Unusual SPIFFE ID making calls
- Policy denies from unexpected sources
- Attestation anomalies
Containment
- Quarantine node (cordon/drain in K8s; isolate at network layer).
- Revoke node identity by:
- deleting node entry / rotating node credentials
- rotating agent keys
- Force workload re-attestation elsewhere.
Eradication
- Rebuild node image; investigate supply chain and runtime escape
- Rotate any affected trust material depending on scope
Runbook E — Policy rollout caused outages (too strict)
Symptoms
- Sudden spike in 403s/denies at proxies
- Only certain routes break
Response
- Roll back policy to last-known-good (keep mTLS on).
- Identify missing allow rules by inspecting denial logs:
- source SPIFFE ID
- destination
- route/method
- Re-apply with a canary:
- namespace/service subset first
- Add tests: “connectivity assertions” in CI (identity-based allowlists)
Putting it together: a reference architecture (minimal moving parts)
- SPIRE Server (or mesh CA) as issuer + bundle distributor
- SPIRE Agent (or mesh node agent) on every node for workload attestation
- Sidecar/ambient proxy enforcing:
- mTLS (AuthN)
- identity-based policy (AuthZ)
- Policy store (mesh config, OPA/Envoy ext_authz, or native mesh auth policies)
- Observability:
- handshake failures
- cert TTL remaining
- denied requests by identity pair
- issuance audit logs
Common pitfalls to avoid
- Using CN instead of SAN URI for identity (breaks interoperability and policy clarity)
- Long-lived leaf certs with no strong revocation plan
- Policies based on IP ranges (reintroduces implicit trust)
- No clock synchronization guarantees
- No “break glass” procedure for bundle rollback and policy rollback
If you share your environment (Kubernetes vs VMs, mesh choice like Istio/Linkerd/Consul/Cilium, and whether you want SPIRE or the mesh CA), I can map the above into concrete implementation steps (SVID delivery method, example SPIFFE ID scheme, and example authZ policies).