Distributed Systems Security and Trust Questions
Security problems that exist because a system is distributed: keeping trust state correct while it propagates across many services, clusters and regions. Covers credential, token and certificate revocation under eventual consistency and network partitions; fleet-wide rotation of signing keys, secrets and trust anchors without outages (key rollover and grace windows, canary rotation, recovery from a compromised root); distributed authorization (replicated policy decision points, cached decisions, fail-open versus fail-closed when an auth dependency degrades); propagating caller identity and permissions through service call chains; tamper-evident audit trails across services and regions (hash chains, Merkle proofs, ordering events with imperfect clocks); Byzantine and partially trusted participants; cross-cluster and cross-organization trust federation; securing shared distributed components such as caches and message brokers against injection, replay and cross-tenant access; protecting data in transit across region boundaries; and tenant isolation as a security blast-radius boundary. Steady-state mTLS, service-mesh identity and network segmentation mechanics are covered by zero-trust service-to-service security; single-system cryptography and KMS basics by applied cryptography.
Design a secure service-to-service authentication and authorization system across multiple clusters and regions. Cover token issuance, short-lived credentials, certificate/key rotation, trust boundaries, least-privilege authorization, fallback when an identity provider is down, and operational practices for key management.
Sample Answer
Direct answer
Give every workload a cryptographic identity issued by its own region's certificate authority after the platform attests what the workload is, and make every credential short-lived so rotation is continuous rather than an event. Authentication happens with mutual TLS (both sides present certificates) using those identities; authorization is a default-deny policy keyed on the caller's identity, evaluated locally. The design principle that answers "what if the identity provider is down" is: verification never needs the issuer online, and issuance is regional with enough credential lifetime left to ride out an outage.
Terms
- Workload identity: a name for a running service, for example the SPIFFE ID
spiffe://prod.eu.example/ns/payments/sa/api(SPIFFE, the Secure Production Identity Framework for Everyone, is an open standard for naming workloads and issuing them certificates, called SVIDs, short for SPIFFE Verifiable Identity Document: the actual certificate or token a workload presents). - Attestation: proving what a workload is from facts the platform controls (its Kubernetes service account, node, image) rather than from something the workload says.
- Certificate chain: a certificate is signed by the authority above it (its issuer); that issuer's own certificate is signed by the authority above it, and so on up to a root. A workload's certificate, at the bottom of that chain, is called a leaf certificate. To trust a leaf, a verifier walks the chain up to a root it already has in its trust bundle; if it has never been told about one of the intermediates in between, it cannot validate anything that intermediate signed, no matter how correctly the leaf itself was issued. That is what "chained to a CA" means, and it is why the rotation order below matters.
- Trust domain / trust boundary: the set of workloads that share a root of trust; crossing a boundary requires explicit federation: the two sides must each deliberately configure trust for specific identities in the other domain, rather than automatically trusting everything the other domain issues.
- Trust bundle: the set of CA (certificate authority) certificates a verifier accepts.
Architecture
flowchart TB
ROOT[Offline root CA] --> ICA1[Intermediate CA: region EU]
ROOT --> ICA2[Intermediate CA: region US]
ICA1 --> AG1[Node agents EU clusters]
ICA2 --> AG2[Node agents US clusters]
AG1 --> W1[Workload certs, 24h]
AG2 --> W2[Workload certs, 24h]
PAP[Policy repo] --> PE1[Local policy check EU]
PAP --> PE2[Local policy check US]
Token and credential issuance
- A node agent (a small process the platform runs on every host, distinct from the application itself) attests the workload using facts it can verify locally: its Kubernetes service account, its namespace (a Kubernetes grouping boundary that scopes and isolates related workloads), and its image digest (a cryptographic hash identifying the exact container image build, so a tampered or swapped image gets a different identity). It then requests a certificate from the regional intermediate CA.
- The workload receives an X.509 certificate (X.509 is the standard format essentially every TLS certificate uses) valid for 24 hours, with its SPIFFE ID in the subject alternative name, a field in the certificate that states which identity or identities it is valid for.
- For calls that also need application-level claims (user on whose behalf, audience), a regional token service issues JWTs (JSON Web Tokens: compact, signed tokens that carry a set of claims, such as who the caller is and who the token is for) valid for 5 minutes with an audience claim, signed with a key whose public half is distributed alongside the trust bundle.
Short-lived credentials and outage tolerance, with numbers
Agents renew a certificate when 50% of its lifetime remains. The worst case for an issuer outage is that it starts at the moment renewal was due, so the tolerance is the remaining lifetime at the renewal point:
| Certificate lifetime | Renew at | Issuer outage the fleet survives | Useful life of a stolen cert |
|---|---|---|---|
| 1 hour | 30 min left | 30 minutes | up to 1 hour |
| 24 hours | 12 h left | 12 hours | up to 24 hours |
| 7 days | 3.5 days left | 3.5 days | up to 7 days |
Commit to 24 hours for certificates. Twelve hours of outage tolerance is long enough to fix a broken CA across a night, and a day is a tolerable exposure window when combined with the other controls. Load is trivial: 50,000 workloads renewing every 12 hours is 50,000 / 43,200 s, about 1.2 issuances per second. The JWT layer stays at 5 minutes because it carries user context, where faster expiry matters more.
Certificate and key rotation
- Leaf certificates rotate continuously by construction.
- Intermediate CAs rotate every few months by overlap: add the new intermediate to trust bundles first, wait until every verifier has the updated bundle, then start issuing from it, and remove the old one only after the last certificate it signed has expired (24 hours plus margin). Reversing that order causes an outage because verifiers reject certificates chained to a CA they have not been told about.
- The root is kept offline in an HSM (hardware security module) and used only to sign intermediates. Root rotation is the same add-then-switch-then-remove sequence stretched over weeks.
- JWT signing keys rotate the same way, publishing the new public key before signing with it.
Trust boundaries
- One trust domain per region (or per environment), not one global domain. A compromised EU intermediate lets an attacker mint EU identities only.
- Cross-region calls use federation: US verifiers are explicitly configured to accept the EU bundle, for specific identities. The US payments service accepts
spiffe://prod.eu.example/ns/checkout/sa/apiand nothing else from EU. - Staging and production never share a root. This is the most common real-world boundary failure.
Least-privilege authorization
Policies are written against identities, not network addresses: "payments accepts calls from checkout on POST /charges; everything else is denied". Policies live in version control, are compiled and pushed to a local enforcement point in every workload (a sidecar, a helper process deployed alongside the application container, or a library linked into the application itself), and are evaluated without a network call. New services start with zero inbound permissions and receive them through review. Every allow and deny is logged with caller identity and policy version.
Fallback when the identity provider is down
Walk through what depends on the issuer:
| Function | Depends on issuer? | Behaviour during outage |
|---|---|---|
| Verifying an existing certificate or token | No: needs only the cached trust bundle and public keys | Unaffected |
| Renewing a workload certificate | Yes | Existing certs keep working for up to 12 hours; alert immediately |
| New pods starting (a pod is the smallest deployable unit in Kubernetes, one or more containers scheduled together on a host) | Yes | Scale-ups and deploys stall; freeze deploys in that region |
| Minting 5-minute JWTs | Yes, regional token service | Fail over to a second token-service instance in the same region; cross-region failover only if the other region's issuer is in the verifiers' federated bundle |
What we deliberately do not do: fall back to a long-lived static shared secret, or disable mTLS. Both turn an availability incident into a security incident. If the outage outlasts the 12-hour tolerance, the controlled response is an emergency extension: issue longer-lived certificates from a standby intermediate held for this purpose, logged and time-boxed.
Operational practices for key management
- Private keys for leaf certs are generated on the host and never leave it; only CSRs (certificate signing requests) travel.
- CA keys live in HSMs or a cloud KMS (key management service); root operations require two people (dual control) and are recorded.
- Monitor: certificate time-to-expiry across the fleet (alert when any workload is under 25% of lifetime), issuance error rates, and bundle version per verifier.
- Rehearse a compromised intermediate: revoke it by removing it from bundles, re-issue the region's workloads from a fresh intermediate, and measure how long that takes. That measured time is your real recovery objective.
Trade-offs and pitfalls
- Short lifetimes replace revocation lists. Certificate revocation lists and OCSP (Online Certificate Status Protocol) checks are rarely reliable at mesh scale (the scale of a service mesh, the network of many services all calling each other over these short-lived certificates); expiry is. The cost is issuer availability, which the table above quantifies.
- Regional isolation costs federation configuration. It is worth it: it bounds a CA compromise to one region.
- Clock skew breaks short-lived credentials. Allow a small skew tolerance (a minute or two) and monitor time sync.
- Common wrong turn: authorizing by IP or namespace label. Those change with every reschedule; identities do not.
You are reviewing the security posture of a shared caching layer (e.g. Redis) and message broker (e.g. Kafka) used by many services on a distributed platform. Walk through the security threats this kind of shared infrastructure is exposed to, and how you would design mitigations at the architecture level for each one you identify.
Sample Answer
Direct answer
A shared cache or message broker is a confused deputy waiting to happen. A confused deputy is a program that has more authority than the party it is currently acting for, and gets tricked into misusing that authority on that party's behalf; here, that means: dozens of services trust the data they read from it, yet any one of those services (or anything that steals its credentials) can usually write to it. The threats that matter are cross-tenant reads, poisoning (injecting or overwriting data other services trust), replay of old messages, denial of service by one noisy client, and plaintext exposure in transit, at rest and in backups. The architecture-level fix is to give every service its own identity with a namespace it alone may write to, authenticate every connection, sign or validate what crosses the shared component, and size the blast radius, how much damage one compromised component or credential can do, by deciding which tenants share a cluster at all.
Why "shared" changes the threat model
A cache inside one service is protected by that service's own boundary. A shared cache or broker is different in two ways:
- Trust is transitive. If the checkout service reads
price:sku-42from Redis and believes it, then anyone who canSET price:sku-42can change prices. The cache has become part of checkout's trusted computing base (the set of components a service implicitly relies on to behave correctly; anything in it can undermine the service's security if it is compromised), but it is administered for everyone. - Credentials are usually coarse. The classic deployment is one Redis password or one Kafka (a distributed log-based message broker: producers append messages to topics, and consumers read them back, usually in place of, or alongside, Redis) principal baked into every service's config. Compromise any one of 80 services and you hold write access to all 80 services' state.
A useful term here: blast radius means how much damage one compromised component or credential can do. Most of the mitigations below are ways of shrinking it.
Threat by threat
| Threat | How it happens on a shared component | Architecture-level mitigation |
|---|---|---|
| Unauthorized read / cross-tenant access | Shared credential; key or topic naming is only a convention; KEYS * or a wildcard consumer subscription reads everyone's data | One principal per service; Redis ACLs restricting each user to a key prefix; Kafka ACLs on prefixed topic names and consumer groups; default deny (Kafka must not run with "allow everyone if no ACL found") |
| Cache poisoning / message injection | A compromised or buggy producer writes a value another service trusts (a price, a session, a feature flag); a rogue producer publishes to a topic a payment consumer processes | Write permission only for the owning service; consumers validate against a schema, using a schema registry (a central service that stores the agreed message format so producers and consumers can check they agree on it) for Avro or Protobuf (compact, schema-based message-encoding formats, as opposed to free-form JSON); for high-value messages, the producer signs the payload so consumers verify origin independent of the broker |
| Replay | An attacker (or an operator resetting consumer offsets, the per-consumer bookmark of how far into a topic it has already read) re-delivers a captured "refund issued" or "grant role" message | Every message carries a unique ID and an issue timestamp; consumers keep a de-duplication store keyed by message ID for at least the replay window and reject messages older than a freshness bound; handlers are idempotent (applying the same message twice has the same effect as once) |
| Topic / key-space hijacking | A service creates a topic or key namespace another team expected to own, or rebinds a consumer group (a named set of consumers that share the work of reading a topic, each partition going to only one member) and steals partitions (the ordered, independently-read shards a Kafka topic is split into) | Topic and consumer-group creation is a platform operation, not a client permission; ACLs on Create, and on consumer groups, not just topics |
| Sensitive data at rest | Session tokens, personal data or access tokens sit in Redis memory, RDB/AOF persistence files (Redis's two on-disk formats: RDB is a periodic full snapshot, AOF is a log of every write, either of which lets Redis survive a restart), Kafka log segments, and backups for their full retention | Do not cache what you cannot afford to leak: cache references or tokenized values; encrypt persistence volumes and backups; for regulated fields, encrypt at the application layer with a per-tenant key so the broker only ever holds ciphertext |
| Eavesdropping in transit | Plaintext Redis protocol or Kafka PLAINTEXT listeners inside a "trusted" network | TLS on every listener, including replication and inter-broker traffic; client certificates or SASL (Simple Authentication and Security Layer, Kafka's pluggable auth framework) for identity |
| Dangerous admin commands | A client can run FLUSHALL, CONFIG SET, DEBUG, or Kafka DeleteTopics / AlterConfigs | Command-level ACLs: application users get data commands only; admin commands belong to a separate, audited operator identity |
| Noisy neighbour / denial of service | Noisy neighbour means one tenant's usage degrades another's, purely by sharing infrastructure, with no compromise needed: one service's hot key, huge values, or runaway producer exhausts memory, network or partitions and takes out every other service | Per-principal quotas (Kafka supports produce/fetch byte-rate and request-rate quotas per user or client ID); maxmemory and eviction policy chosen per cluster; for critical tenants, a separate cluster |
| Stale security state | A revoked service's credential still has a live, authenticated connection | Short-lived credentials, and on revocation actively kill sessions (CLIENT KILL USER, or rotate and drop the principal) instead of waiting for reconnect |
Worked example: prefix isolation you can run
The single highest-value change is replacing the shared password with per-service ACL users. This runs against a stock Redis 7 container:
docker run -d --name cache-demo redis:7-alpine
docker exec -i cache-demo sh <<'EOF'
# ACL SETUSER <name> <rules...>. 'on' enables the user (a new user starts disabled).
# '>orders-pw' sets that password (the '>' means "add this password"; '<' would remove one).
redis-cli ACL SETUSER orders-svc on '>orders-pw' '~orders:*' '+get' '+set' '+del'
redis-cli ACL SETUSER billing-svc on '>billing-pw' '~billing:*' '+get' '+set'
redis-cli --user billing-svc --pass billing-pw --no-auth-warning SET billing:invoice:77 paid
redis-cli --user orders-svc --pass orders-pw --no-auth-warning SET orders:1001 pending
redis-cli --user orders-svc --pass orders-pw --no-auth-warning GET billing:invoice:77
redis-cli --user orders-svc --pass orders-pw --no-auth-warning KEYS '*'
redis-cli --user orders-svc --pass orders-pw --no-auth-warning FLUSHALL
redis-cli --user orders-svc --pass orders-pw --no-auth-warning GET orders:1001
EOF
docker rm -f cache-demo
Output (executed on Redis 7.4):
OK
OK
OK
OK
NOPERM No permissions to access a key
NOPERM User orders-svc has no permissions to run the 'keys' command
NOPERM User orders-svc has no permissions to run the 'flushall' command
pending
Reading it: on turns the new user on (a freshly created ACL user starts disabled, on purpose, so an incomplete definition never silently grants access); >orders-pw sets its password; ~orders:* confines the orders service to its own key prefix, so it cannot read the billing invoice; +get +set +del is a command allow-list, so it cannot enumerate the key space or wipe the database. In production you would also disable the default user, load users from an ACL file managed by your secrets pipeline, and put TLS on the port. (Passwords on the command line are for the demo only.)
The Kafka equivalent, expressed as the actual ACL you would create with Kafka's kafka-acls tool:
kafka-acls --bootstrap-server localhost:9092 --add \
--allow-principal User:orders-svc \
--operation Write --topic orders. --resource-pattern-type prefixed
kafka-acls --bootstrap-server localhost:9092 --add \
--allow-principal User:orders-svc \
--operation Read --group orders-svc-group
This grants orders-svc Write on any topic whose name starts with orders. and Read on its own consumer group, and nothing at all on billing. topics, the same prefix-isolation shape as the Redis ACLs above.
Choosing the isolation level: commit to a tiered model
Namespacing inside one cluster (logical isolation) stops reads and writes across tenants but not resource starvation: one service can still exhaust the shared Redis's memory. So:
- Default: pooled cluster, per-service identity, prefix ACLs, quotas. Right for the long tail of internal services with ordinary data.
- Dedicated cluster for anything whose poisoning or outage is a business incident on its own: sessions, payment events, authorization caches. The cost is more clusters to operate; the gain is that a noisy or compromised neighbour physically cannot touch it.
- Per-tenant encryption keys where customers are the tenants and regulation or contracts require it, so deleting a tenant's key renders their residual data in logs and backups unreadable (sometimes called crypto-shredding).
What would flip the default toward dedicated clusters for everyone: a small number of services with very different trust levels (for example, a third-party-code plugin runner sharing a cache with the payments service). Mixing trust levels in one pool is the real risk, not sharing as such.
Trade-offs and pitfalls
- ACLs without identities are theatre. If all 80 services still load the same ACL user from a shared config file, prefix ACLs isolate nothing. The identity must be per service and delivered by the secrets system.
- Signing everything is expensive and rarely needed. Broker ACLs already stop outsiders; payload signatures earn their cost only where a consumer must not trust other legitimate producers (financial events, authorization changes).
- Replay protection needs state. A de-duplication window of 24 hours at 5,000 messages per second is 5,000 x 86,400 = 432 million IDs; at roughly 16 bytes per ID that is about 6.9 GB before overhead, so bound the window to what an attacker could realistically replay and pair it with a timestamp freshness check.
- Audit the shared component itself. Log authentication failures, ACL denials and admin commands, and alert on them; a burst of
NOPERMfrom one service is either a bug or a compromise. - Common wrong turn: relying on network segmentation ("it is only reachable inside the VPC (Virtual Private Cloud)"). Every service inside that network is exactly the population the threats above come from.
A root signing key used to mint service identity certificates was discovered to be compromised. You are the SRE lead. Produce an incident response and remediation plan: immediate containment and revocation steps, how to remove the compromised trust anchor, re-issue a new CA and rotate workload certificates at scale (millions of instances), communicate with external partners, and minimize downtime while making the system secure again. Discuss cryptographic constraints, rollback strategies, and monitoring to verify success.
Sample Answer
Direct answer
A compromised root is not something you can "revoke" in the usual sense: a root CA (certificate authority) is a trust anchor, a key every workload trusts because it is in their configured trust bundle, and the only way to stop trusting it is to remove it from every bundle. So the plan is: stop the bleeding (freeze the compromised key, hunt for attacker-minted certificates, shrink what the old root can vouch for), stand up a new root in a clean ceremony, run a short dual-trust window in which workloads trust both roots while every certificate is re-issued from the new one, then remove the old root everywhere and verify that nothing still presents or accepts it. Downtime is avoided by ordering: trust the new root first, re-issue second, distrust the old root last. The hard constraint is that during the dual-trust window the attacker's certificates are still trusted, so that window must be short and watched.
Phase 0: first hour, containment and scoping
- Declare the incident, name an incident commander, open a war room, start a timeline. Legal and communications join now, not later.
- Freeze the key: disable the compromised key in the HSM (hardware security module), revoke every credential and role that could invoke it, and stop all automated issuance that chains to it. Preserve logs and host images for forensics.
- Scope the compromise: was the key exfiltrated (copied out, so the attacker can sign anything, forever) or was the signing service abused (the key never left; the attacker could only request signatures during a known window)? The second case is much smaller: every certificate the attacker got is in your issuance logs.
- Hunt attacker certificates: compare every certificate seen in the wild (mesh proxy handshake logs: the connection logs a service mesh, the network of small proxies, one per workload, that carries and secures service-to-service traffic, writes each time its proxies complete a TLS handshake, the negotiation in which client and server exchange and verify certificates before encrypted traffic starts; plus load balancer logs) against your issuance log. Any certificate that chains to the root but is not in your log is attacker-minted and tells you what they are impersonating.
- Short-term guardrails while you prepare the replacement: tighten authorisation so that high-value services (payments, identity, secrets) accept only an allowlist of SPIFFE IDs (workload identity names under the SPIFFE standard, Secure Production Identity Framework For Everyone) or certificate serials (the unique serial number stamped on each certificate you issue, so you can allowlist exactly the ones your own issuance log shows as legitimate) you issued; raise alerting on new identities appearing.
Phase 1: build the new trust anchor
- Ceremony: generate the new root offline in an HSM with M-of-N custody (for example 3 of 5 custodians must be present), witnessed and recorded. Do not reuse any host, HSM partition, pipeline or credential from the old chain until forensics clears it.
- Design it to fail smaller next time: a certificate chain has three tiers: the root (the offline trust anchor itself), intermediates (subordinate CAs the root signs once, which do the day-to-day signing so the root never has to come online), and leaf certificates (the end-entity certificates a workload actually presents on a connection, signed by an intermediate). Keep the root offline and issue per-region or per-environment intermediates, each with a path length constraint of 0 (it can sign leaf certificates but not further CAs) and, where your clients enforce them, name constraints (limit which names or URI SANs, the subject alternative names that carry SPIFFE IDs, an intermediate may certify). A future intermediate compromise then affects one region, and the root never touches the network.
- Do not cross-sign the new root with the old one. Cross-signing means having one root issue a certificate over the other root's public key, so anyone who already trusts root A automatically trusts anything root B signs too; that is how you migrate trust between two healthy roots, but here it would let the untrusted old root vouch for the new one, handing the attacker a path back in.
Phase 2: dual trust, then rotate millions of workloads
flowchart LR
A[Bundle: old root only] --> B[Bundle: old + new root]
B --> C[Re-issue all leaf certs from new chain]
C --> D[Bundle: new root only]
D --> E[Verify: no old-chain handshakes]
C -. "rollback target" .-> B
Step A to B, push the new bundle. Every workload must trust the new root before anything presents a new-chain certificate, or handshakes fail. Distribute through the normal channel (the mesh's trust bundle distribution, SPIRE, the SPIFFE Runtime Environment, or the service mesh control plane) and gate the next step on telemetry: 100% of proxies reporting the new bundle version.
Step B to C, re-issue at scale. Workloads fetch new leaf certificates from the new intermediates. This plan commits to a 6-hour re-issuance window as the target (a business-hours window with slack for retries and backoff); 2 hours is shown only as the aggressive case worth checking your infrastructure against, not a promise the plan makes. Capacity arithmetic for 2 million instances:
6 h×3,600 s/h2,000,000 certs≈92.6 signatures/s (the committed target),2×3,6002,000,000≈277.8 signatures/s (the aggressive case)Split across regional intermediates both rates are modest, but verify each against your issuer's measured signing rate and your HSM's, and add jitter so 2 million agents do not stampede in the first minute. Roll out by ring (deploy in expanding waves, each one gated on the previous wave's health before the next starts): internal tooling, then one low-risk region, then the rest, with automatic pause on handshake-error spikes. Workloads keep serving while they rotate; existing connections complete, and new connections use the new certificate.
Step C to D, distrust the old root. Once telemetry shows no workload presenting an old-chain certificate, push bundles containing only the new root. This is the moment the attacker's certificates stop working.
Window length: this whole A-to-D sequence should be hours, not weeks. If automation allows, target same day. The window is your exposure.
External partners
- Notify partners who trust your root (federation, mTLS (mutual TLS) integrations where both sides present certificates, customer devices) with: what happened at a level legal approves, the new root's fingerprint (a short cryptographic hash of the root certificate, unique enough that comparing it byte for byte confirms a partner has the genuine new root and not a substitute), and a firm deadline for removing the old one.
- Deliver the fingerprint out of band (a signed advisory on a separate channel plus a phone confirmation between named contacts), never only in an email that could come from the attacker.
- Offer a validation endpoint partners can test against before the cutover; track each partner's status on a board. Partners who miss the deadline lose connectivity rather than keeping a compromised trust path open, and that decision is made in advance by an executive, not improvised.
Cryptographic constraints to plan around
- No CRL (certificate revocation list) or OCSP (Online Certificate Status Protocol) for roots. Revocation lists are signed by the issuer; a root's "revocation" would be signed by the compromised key itself. Bundle removal is the only mechanism.
- Every certificate issued under the old root is untrustworthy, including legitimate ones, because the attacker can mint identical-looking ones. Everything gets re-issued.
- Pinned and embedded roots (firmware, mobile apps, appliances, partner configs) cannot be updated by your control plane. Inventory them first; they set your real deadline.
- Clock skew: issue new certificates with a small backdated
notBeforeso slightly slow clocks do not reject them. - Algorithm choice: take the opportunity to use the current recommended key type (for example ECDSA, the elliptic curve digital signature algorithm, on P-256 or P-384) and plan how you would do this again; the rotation you are rehearsing now is also your future crypto-agility.
Rollback strategy
Rollback never means going back to trusting only the old root. The safe rollback target is the dual-trust state (B): if re-issued certificates break something, revert those workloads to their old-chain certificate, which still works in state B, fix, and retry. Keep bundle versions immutable and numbered so "roll back to bundle v41" is one command. Once you reach state D, rolling back re-opens the attacker's access, so it requires incident-commander sign-off.
Monitoring to verify success
- Bundle version per proxy (target 100% on each step before moving on).
- Handshakes by issuing chain: old-chain presentations should fall to zero before step D, and old-chain acceptances must be zero after it.
- Handshake failure rate per service and region during each ring (the canary signal for pausing).
- Certificates observed that are absent from the issuance log (should be zero on the new chain; any hit is a new incident).
- Partner cutover status and synthetic probes from partner-like clients.
Trade-offs and pitfalls
- Speed vs safety: a same-day rotation risks breakage; a slow one leaves the attacker trusted. Pre-built automation and quarterly root-rotation drills are what let you have both.
- Minimising downtime by skipping step A (pushing new certificates before new trust) is the classic self-inflicted outage.
- Forgetting non-mesh consumers (batch jobs, databases with client-certificate authentication, VPN concentrators) leaves pockets that break at step D or, worse, keep trusting the old root silently.
Your organization runs across 4 Kubernetes clusters, 3 cloud providers, and several third-party SaaS integrations, and needs a zero-trust architecture spanning all of them. Requirements: per-service identity, cross-org trust federation, least-privilege access, full auditability, and the ability to revoke cross-org access within 30 seconds. Describe your trust model (federated vs centralized CA), certificate issuance and attestation flows, policy enforcement points, and the SRE operational model for rotation, emergency revocation, and audits.
Sample Answer
Direct answer
Zero trust means no request is trusted because of where it comes from (inside a VPC, Virtual Private Cloud, or a cluster network); every call must prove who is calling and be checked against policy. For 4 clusters, 3 clouds and external SaaS, I would use a federated trust model: each cluster or cloud is its own trust domain with its own issuing CA (certificate authority) whose keys sit in that environment's HSM (hardware security module) or KMS (key management service), and domains trust each other by exchanging signed trust bundles, the set of CA certificates a domain has agreed to accept as valid issuers, not by sharing one global root. Workloads get short-lived, attested identities (SPIFFE IDs, a workload identity standard defined below, issued by SPIRE, its reference implementation), enforcement happens at proxies and gateways that pull policy continuously, and the 30-second cross-org revocation is met by pushing a deny policy to enforcement points and cutting live connections, because certificate revocation lists are far too slow for a 30-second promise.
Trust model: federated vs centralized CA
| Centralized CA (one root, one issuer) | Federated (one CA per trust domain, bundles exchanged) | |
|---|---|---|
| Blast radius of a CA compromise | Everything, everywhere | One domain; others drop its bundle |
| Cross-cloud latency / dependency | Every issuance crosses clouds | Issuance is local to each domain |
| Partner / SaaS fit | Partners must trust your root | Natural: they are just another trust domain |
| Operational effort | One thing to run | Bundle distribution and policy per domain |
Commit: federated, with one offline root of your own that signs each internal domain's intermediate, a subordinate CA certificate, signed by your root, that does the actual day-to-day issuing so the root itself can stay offline and rarely touched (so your own domains can share one root of trust for convenience) and separate, explicit federation relationships with external organisations, whose CAs you never chain to your root. What would flip it: a single small cloud estate with no external partners, where one CA is simpler and the blast-radius argument is weak.
SPIFFE (Secure Production Identity Framework For Everyone) is the open standard for workload identity: every workload gets an ID such as spiffe://prod.aws.example.com/ns/payments/sa/api, delivered as an SVID (SPIFFE Verifiable Identity Document), usually a short-lived X.509 certificate. SPIRE (the SPIFFE Runtime Environment) is the reference implementation that issues them and supports federation between trust domains.
flowchart TB
subgraph Org[Your organisation]
Root[(Offline root, HSM)]
A[SPIRE: AWS clusters] --- B[SPIRE: GCP cluster]
B --- C[SPIRE: Azure cluster]
Root -.signs intermediate.-> A & B & C
end
P[Partner trust domain] <-- "bundle exchange + policy" --> A
S[SaaS via OIDC federation] <-- "short-lived tokens" --> EG[Egress gateway]
A --> PEP[Envoy sidecars / gateways + policy engine]
Issuance and attestation flows
Attestation is how the issuer decides a workload deserves an identity, based on evidence it cannot fake, rather than on a secret someone copied into a config file.
- Node attestation: the SPIRE agent on a node proves what machine it is using the platform's own signed evidence, not a secret it holds itself: a Kubernetes projected service account token (a short-lived, audience-scoped token the cluster mints for that pod), an AWS instance identity document (a signed description of the EC2 instance that AWS itself vouches for), a GCP instance identity token (Google Cloud's equivalent signed statement), or an Azure managed identity (an identity Azure attaches to the VM or resource automatically, with no credential for anyone to copy). All four do the same job, prove the hardware or platform is who it claims to be, using whichever evidence that cloud or cluster natively signs.
- Workload attestation: the agent inspects the calling process (namespace, service account, image digest) and matches it to a registration entry.
- Issuance: the SPIRE server signs a short-lived SVID (1 hour here); the agent rotates it at half-life, meaning it requests a fresh one once 30 minutes (half of the 1-hour lifetime) have elapsed, so there is always a safety margin before the old one expires and workloads never hold a long-lived secret.
- To SaaS: most SaaS providers do not accept mTLS (mutual TLS: unlike ordinary TLS, both sides present a certificate and verify each other, not just the client verifying the server) from your workloads. Use OIDC workload identity federation (OIDC, OpenID Connect, is the identity layer on OAuth 2.0): the workload presents its JWT-SVID, its SPIFFE identity encoded as a JWT (JSON Web Token, a signed, self-contained token format) instead of the X.509 certificate form used inside the mesh, to the SaaS provider's or cloud's token service and receives a short-lived access token. No static API keys.
Load check: 4 clusters x 5,000 workloads each = 20,000 identities; rotating 1-hour SVIDs at half-life means 20,000 / 1,800 s, about 11 signatures per second. Trivial for any issuer; the real risk is a thundering herd, a burst of workloads all renewing at once (for example every SVID issued at the same moment during an outage recovery, so they all hit half-life together) that spikes load on the issuer, so add jitter to renewals.
Least privilege and policy enforcement points
- PEPs (policy enforcement points) are where a request is allowed or denied: Envoy (an open-source proxy) sidecars, a small proxy process deployed alongside each workload container that intercepts its traffic, or per-node proxies for east-west traffic (service-to-service calls inside the environment, as opposed to north-south traffic entering or leaving it), ingress gateways for inbound partner traffic, an egress gateway for all calls to SaaS and partners.
- Policy: authorisation rules written against SPIFFE IDs ("
payments/apimayPOST /chargeonledger"), evaluated locally by a policy engine such as OPA (Open Policy Agent), with default deny. - Distribution: policy is compiled centrally and pushed to proxies over xDS, Envoy's family of discovery APIs that lets a proxy pull its routing, cluster and policy configuration from a central control plane instead of reading a static file, so a change reaches every proxy in seconds, not on the next deploy.
Meeting 30-second cross-org revocation
X.509 revocation (CRLs, certificate revocation lists, and OCSP, the Online Certificate Status Protocol) is fetched and cached for hours, and short SVIDs of even 5 minutes cannot meet 30 seconds. So revocation is a policy action, not a certificate action:
| Step | Mechanism | Budget |
|---|---|---|
| Revoke command recorded | Control plane writes "deny trust domain partner.com" | 1 s |
| Push to all PEPs | xDS push to every proxy and gateway in all 4 clusters | p99 (99th percentile) 5 s |
| Kill existing connections | Proxies drain and close connections from/to that domain | 10 s |
| Remove federation bundle | Stop trusting the partner CA for new handshakes | in parallel |
| Verify | Synthetic partner-identity probe must get denied everywhere | 10 s |
| Total | about 26 s, inside 30 |
The connection-kill step is the one people forget: an mTLS connection established before revocation stays authenticated until closed. For outbound access to a SaaS, you cannot control the SaaS provider's revocation speed, so enforce at your own egress gateway and additionally revoke the federated credential at the provider.
SRE operational model
- Rotation: SVIDs rotate automatically; intermediates rotate yearly with overlap (new bundle published before the new intermediate issues); the offline root is used only in ceremonies requiring M-of-N key custodians (M of a set of N trusted people must each show up and jointly authorise the root's use, so no single person can act alone).
- Emergency revocation drills: run the partner-revocation play quarterly against a test trust domain and measure the 30-second SLO (service-level objective) end to end.
- Monitoring: SVID expiry histogram (anything within 10 minutes of expiry means rotation is failing), attestation failures by node type, xDS config version skew across proxies, denied-request rates by source trust domain, and bundle freshness per federated domain.
- Audit: every issuance, attestation decision, policy change and allowed/denied cross-domain call is logged with both SPIFFE IDs to an append-only store, so "who could reach what, and when" is answerable later.
Trade-offs and pitfalls
- Federation sprawl: each partner is a trust relationship to review; keep a registry with an owner and expiry date per relationship.
- Sidecar cost: a proxy per pod adds memory and latency; node-level or sidecar-less mesh modes, where one shared agent per node or the workload's own library enforces policy instead of a dedicated proxy container per pod, reduce it but concentrate more identities per enforcement point.
- Break-glass: if the policy control plane is down, proxies keep their last known policy (fail static), which is the right default, but it means revocations cannot land; alert on control-plane health as a security signal, not just an availability one.
Your platform needs a secrets and API key management system for services sitting behind an API gateway. It must support zero-downtime key rotation, immediate revocation, audit logging, and minimal blast radius if a key leaks. Explain the storage model, how keys get distributed to gateways and services, how you would orchestrate rotation, and the emergency revocation flow.
Sample Answer
Direct answer
Split the problem into two kinds of secret. Client API keys (presented by callers to the gateway) are stored only as hashes in a central key registry and pushed to gateways as a versioned, in-memory snapshot plus a change stream (a continuous feed of create, scope-change and revoke events, so a gateway only has to apply what changed rather than re-fetch everything), so a gateway can validate a key locally and a revocation reaches every gateway in seconds. Service secrets (database passwords, third-party credentials) live in a secrets manager, encrypted under keys held in a KMS (key management service) or HSM (hardware security module), and are fetched at runtime by workloads that authenticate with their platform identity, never with a secret baked into an image. Rotation always runs through a window where old and new are both valid; revocation skips that window and is pushed, acknowledged and audited.
Terms
- Blast radius: how much one leaked key can do. Shrink it with per-client, per-environment, narrowly scoped, short-lived credentials.
- Envelope encryption: each secret is encrypted with its own data key, and that data key is encrypted with a master key that never leaves the KMS/HSM.
- Secret zero: the first credential a brand-new workload needs in order to fetch all its other secrets. How you bootstrap it decides whether the whole design is sound.
Storage model
flowchart LR
ADM[Key admin API] --> REG[(Key registry: hashes + metadata)]
REG --> STR[Change stream]
STR --> G1[Gateway region A]
STR --> G2[Gateway region B]
SM[(Secrets manager)] --> KMS[KMS or HSM master key]
W[Service workload] -->|platform identity| SM
REG --> AUD[(Append-only audit log)]
SM --> AUD
Client API keys. Generate 256 random bits, format as pk_live_<keyid>_<secret>. Store keyid, SHA-256(secret), owner, scopes, environment, status, created and expiry times. Never store the key itself: it is shown once at creation. A fast hash is correct here (unlike passwords): passwords are hashed with deliberately slow algorithms like bcrypt because people choose low-entropy, guessable values, so the hash must be expensive enough to make guessing infeasible. A 256-bit random secret has no such weakness: it cannot be brute-forced regardless of hash speed, so bcrypt's deliberate slowness buys nothing and would add latency on every request. The keyid prefix lets gateways look up the record in one step and lets secret-scanning tools (automated scanners that watch code repositories for accidentally committed credentials) recognise a leaked key in a public repository.
Service secrets. Stored in the secrets manager under envelope encryption, organised by path per service and environment (prod/orders/db), with a policy granting each workload identity exactly its own paths. Prefer dynamic secrets where the backend supports them: the secrets manager creates a unique database user per workload with a lease (a grant that expires automatically unless the workload renews it before the deadline) of, say, 1 hour, so there is nothing long-lived to leak and each credential is attributable to one workload.
Sizing the gateway snapshot. With 2,000,000 active client keys at about 32 bytes of hash plus 100 bytes of metadata each: 2,000,000 x 132 = 264,000,000 bytes, about 252 MiB. That fits in gateway memory, so every validation is a local lookup with no network call. If it did not fit, gateways would cache on demand with a short TTL (time-to-live) and fall back to the registry on a miss.
Distribution to gateways and services
- Gateways load a full snapshot at start-up (tagged with a version number), then apply a change stream of
created / scope_changed / revokedevents in order. Each gateway reports the version it has applied, so the control plane (the system that manages and coordinates gateway configuration, as distinct from the data plane that carries live request traffic) always knows the laggards, the gateways that have fallen behind the latest version. If the stream breaks, the gateway re-fetches a snapshot; if it cannot, it keeps serving from its last snapshot and alerts, because refusing all traffic is worse than a snapshot a few minutes old, except for revocations (see below). - Services fetch their secrets at start-up through a local agent (a sidecar: a helper process deployed alongside the application container that does this fetching and renewal on the app's behalf), which renews leases before expiry and writes secrets to an in-memory file the app re-reads, so rotation does not require a redeploy.
Secret zero: bootstrapping a brand-new workload
The failure pattern is putting a long-lived token in CI (continuous integration) variables or the container image so the new container can log in to the secrets manager. Instead, let the platform vouch for the workload:
- CI/CD pipeline: the CI provider issues a short-lived OIDC (OpenID Connect) token describing the exact repository, branch and job; the secrets manager or the cloud provider's security token service (STS) trusts that issuer and exchanges the token for credentials scoped to that pipeline. No static secret exists in CI at all.
- Ephemeral containers: Kubernetes projects a service-account token that is audience-bound (it can only be redeemed by the exact service it was issued to, not replayed elsewhere) and expires; the agent presents it, the secrets manager validates it against the cluster and returns a short-lived token for that service's paths. On a cloud VM the equivalent is the instance identity document: a document signed by the cloud provider itself, attesting which specific VM instance is making the request.
- When no platform identity exists, use a single-use, short-lived wrapped token delivered by the deploy system (Vault calls this response wrapping: the secrets manager seals the real credential in an envelope that can be opened, or "unwrapped," exactly once): if an attacker used it first, the legitimate workload's unwrap fails and that failure is itself the alarm.
Zero-downtime rotation orchestration
For client API keys, rotation is the client's action, so the platform must allow two active keys per client:
- Client (or automation) creates key B; A and B are both valid.
- Client deploys B; the gateway emits
last_usedper key ID, so both sides can see traffic migrate from A to B. - When A has had zero traffic for a set period (for example 7 days), A is revoked. Keys also carry an expiry (for example 1 year), with warnings at 30 and 7 days.
For service secrets:
- Create the new credential in the backend (new DB password or user) while the old one stays valid.
- Publish it to the secrets manager as a new version; agents pick it up on their next refresh.
- Wait until every consumer reports the new version (or until one full refresh interval plus margin has passed).
- Disable the old credential, then delete it after a cooldown. If error rates rise after step 4, re-enabling the old credential is the rollback, which is why you disable before deleting.
Emergency revocation flow
Leak detected (secret scanner hit, anomaly alert or customer report):
- Revoke in the registry: status
revoked, with reason and actor recorded in the audit log. - Push: the revocation event goes on the change stream with priority; gateways apply it and acknowledge by version. Target: 99% of gateways within 5 seconds.
- Bound the tail: a gateway that has not acknowledged within the deadline is marked unhealthy and removed from the load balancer until it catches up. This turns "eventually revoked" into "revoked, or not serving traffic".
- Scope the damage: query the audit log for every request made with that key ID since the suspected leak time.
- Replace: issue a new key to the owner; for a service secret, rotate immediately without the normal overlap window, accepting a brief error spike.
Audit logging
Every key creation, scope change, revocation, secret read and failed authentication is written to an append-only store in a separate account that application operators cannot delete from. Log key IDs, never key material. Alert on reads from an unexpected identity, a spike in failed validations for one key ID (someone guessing), and use of a key from a new network or country.
Trade-offs and pitfalls
- Local validation vs instant revocation: local snapshots make validation fast and resilient but make revocation a distributed-propagation problem. The acknowledgement-plus-eviction step is what closes that gap; without it you only have "probably revoked".
- Rotation that requires a restart is rotation nobody runs. Hot reload of secrets is a prerequisite.
- Scoping is the cheapest blast-radius control: a key that can only read
ordersinstagingis a far smaller incident than a master key. - Common wrong turn: encrypting API keys reversibly "so support can look them up". If the platform can decrypt them, so can whoever compromises the platform.
Unlock Full Question Bank
Get access to all 12 Distributed Systems Security and Trust interview questions and detailed answers.
Sign in to ContinueJoin thousands of developers preparing for their dream job.