Skip to main content

Security Incident & Breach Response, Key Compromise

Level 8: Level 8: Security, Privacy & Multi-tenancyhard35 minsecurityincident-responsecompliance

Run detection, containment, eradication, recovery, lessons in order; rotate the compromised key via overlapping JWKS validity plus shortened TTLs so nobody is logged out; preserve evidence before cleanup with chain of custody; and start the GDPR 72-hour notification clock the moment you become aware.

Panic causes two classic mistakes

When a key or credential is compromised, panic causes two classic mistakes: wiping systems immediately (destroying the evidence you need) and doing a hard key cutover (logging every user out). A senior responder runs a disciplined loop instead.

The NIST-style loop

Detection  -> know something is wrong
Containment-> stop the bleeding without destroying evidence
Eradication-> remove the foothold, rotate secrets
Recovery   -> restore trusted state, watch for reinfection
Lessons    -> blameless postmortem, fix root cause

Detection. Feed everything into centralized logging or a SIEM (Splunk, Elastic, a cloud-native equivalent) and alert on anomalous key usage: geo-velocity impossibilities (the key signs from two continents a minute apart), unusual volume, or calls at odd hours. Seed honeytokens (a fake credential that should never be used, so any use is a certain intrusion signal). And plan for the humbling reality that an outside party (a researcher, a customer, law enforcement) often notifies you first, so build an intake path for external reports.

Check yourself
The SIEM confirms a signing-key compromise. Your on-call wants to wipe and reimage every affected host right now, to be safe. What does that decisiveness cost?

Containment without destroying evidence. Isolate affected systems (pull them from the load balancer, cut network egress) and revoke active sessions, but do not wipe yet. This is the phase where the discipline matters most.

Check yourself
The compromised key signs every session token in the product. The fastest fix on the table: delete it from the key set immediately. What happens the moment you do?

Rotate a widely-used key without downtime

If one signing key protects every session and you just delete it, every valid token instantly becomes invalid and the whole userbase is logged out. The answer is to design for overlapping key validity ahead of time. Publish keys via a JWKS (JSON Web Key Set) endpoint with a key id (kid) in each token header. To rotate: (1) add the new key to the JWKS so verifiers accept both old and new, (2) flip signing to the new key, (3) after tokens signed with the old key have expired, remove the old key. Because verifiers trust both during the overlap, nobody is logged out. Under compromise you compress this: shrink token TTLs immediately so old tokens age out fast, force re-authentication for genuinely affected sessions, and pull the compromised kid from the JWKS. Short-lived credentials from a secrets manager (Vault, cloud KMS) make this routine rather than heroic.

Eradication and recovery. Remove the attacker's foothold, rotate all potentially-exposed secrets, then restore from a known-good state and watch closely for reinfection. This is where immutable, object-locked backups pay off: if the attacker also ran ransomware, a ransomware-resistant backup is your clean recovery path.

Forensics and the legal clock, in parallel

The instant you suspect a breach, evidence preservation starts: snapshot affected volumes and preserve immutable logs before you clean anything, and maintain chain of custody so the evidence holds up later. Simultaneously the regulatory clock starts: GDPR requires notifying the supervisory authority within 72 hours of becoming aware of a qualifying breach, and affected users without undue delay if there is high risk. So legal and comms are named roles in the runbook, activated at hour zero, not consulted after cleanup.

Interview nuance: the trap is optimizing for "fix it fast." Wiping and rebuilding immediately feels decisive but destroys forensics and, with a hard key cutover, causes a self-inflicted outage on top of the breach. The strong answer sequences containment before eradication, rotates keys via overlapping validity, and runs forensics and the 72-hour legal clock in parallel from the start.

Recap: run detection, containment, eradication, recovery, lessons in order; rotate the compromised key via overlapping JWKS validity plus shortened TTLs so nobody is logged out; preserve evidence before cleanup with chain of custody; and start the GDPR 72-hour notification clock the moment you become aware.

Check yourself

Hour zero of a confirmed breach. Sort each action: does it start now, in parallel with everything else, or only after evidence is preserved?

Snapshot affected volumes and lock down the logs
Activate legal and start the GDPR 72-hour notification clock
Pull affected systems from the load balancer and cut egress
Add the new signing key to the JWKS and shrink token TTLs
Wipe compromised hosts and restore from known-good state

Apply

Your turn

The task this lesson builds to.

Design the incident and breach response plan for a compromised signing key in a multi-tenant SaaS, covering detection, containment, key rotation and revocation without downtime, forensic evidence, and regulatory notification.

Think about

  1. What are the ordered phases of incident response, and what is the goal of each?
  2. How do you rotate and revoke a widely-used key without taking the whole system down?
  3. What legal and forensic obligations start the moment you confirm a breach?

Practice

Make it stick

A second problem on the same idea, so it survives past today.

Design the breach response for a compromised root Certificate Authority signing key at a payments provider (a Stripe-scale system) where the key secures mTLS between thousands of internal services and any rotation risks a full internal outage.

Think about

  1. Why is a root CA harder to rotate than a JWT signing key?
  2. How does cross-signing plus staged trust distribution avoid a total outage?
  3. How do you contain the compromise while the staged rotation is in flight?