Today’s Lesson
Security for Legal SaaS — Episode 29: Key Management and Rotation
Your Encryption Is Only as Strong as Your Key Management
In Episode 28, we covered encryption at rest and in transit — the two fundamental layers that protect legal data from eavesdroppers and stolen disks. But encryption without proper key management is theatre. A key stored next to the data it protects is like locking a filing cabinet and taping the key to the front. The lock exists, but the security does not.
This episode focuses on the infrastructure that makes encryption actually work: how cryptographic keys are generated, stored, rotated, and retired — and why getting this wrong has caused some of the most damaging breaches in legal technology.
The Key Hierarchy: Master Keys, Data Keys, and Envelope Encryption
Modern key management uses a layered hierarchy rather than a single key for everything. The pattern is called envelope encryption, and it works like a chain of locked boxes:
| Layer | Purpose | Example |
|---|---|---|
| Master key (root key) | Protects all other keys; never touches data directly | AWS KMS root key, GCP Cloud KMS key |
| Key-encrypting key (KEK) | Wraps data encryption keys for storage and transport | Intermediate key in a Vault transit backend |
| Data encryption key (DEK) | Encrypts actual data (documents, database fields, files) | AES-256 key generated per-record or per-tenant |
When your case management system encrypts a client's document, it generates a fresh DEK, encrypts the document with that DEK, then encrypts the DEK itself with the master key. The encrypted DEK is stored alongside the encrypted document. The plaintext DEK is discarded immediately. To decrypt, the system asks the key management service (KMS) to unwrap the DEK using the master key, then uses the plaintext DEK to decrypt the document.1
This means the master key never leaves the KMS boundary. Even if an attacker steals your entire database — encrypted documents and encrypted DEKs included — they cannot decrypt anything without access to the master key inside the KMS.2
Why this matters for legal SaaS: If your platform stores privileged attorney-client communications, opposing counsel's discovery documents, and merger negotiations in the same database, envelope encryption lets you use different DEKs per client matter. Compromising one matter's key does not expose another.
Key Management Services: The Hardware Behind the Trust
A key management service is a specialised system — often backed by tamper-resistant hardware called a Hardware Security Module (HSM) — that generates, stores, and performs cryptographic operations with master keys. The master key material never leaves the HSM boundary in plaintext.
| Service | Provider | HSM Backing | Key Rotation | Pricing Model |
|---|---|---|---|---|
| AWS KMS | Amazon | FIPS 140-2 Level 3 | Automatic (annual) or on-demand | Per-key + per-request |
| Cloud KMS | Google Cloud | FIPS 140-2 Level 3 | Automatic (configurable period) | Per-key-version + per-operation |
| Azure Key Vault | Microsoft | FIPS 140-2 Level 2/3 | Manual or policy-based | Per-operation + per-key |
| HashiCorp Vault | HashiCorp | Optional HSM backend | Policy-driven | Self-hosted or HCP managed |
For a legal SaaS platform, the choice typically depends on your cloud provider. If you run on AWS, KMS is the natural default. The critical requirement is that the KMS is a separate trust boundary from your application servers and database. Your application can request encryption and decryption operations, but it never possesses the master key.3
Key Rotation: Why and How
Cryptographic keys should not last forever. NIST SP 800-57 defines cryptoperiods — the maximum lifespan during which a key is authorised for use. The reasons for rotation include:4
- Limiting exposure. If a key is compromised without detection, limiting its cryptoperiod limits how much data the attacker can decrypt.
- Reducing ciphertext volume. The more data encrypted with a single key, the more material an attacker has for cryptanalysis.
- Compliance. PCI DSS, SOC 2, and various data protection regulations mandate periodic key rotation.
How Rotation Works Without Downtime
The elegant aspect of envelope encryption is that key rotation only rotates the master key — not every DEK in your system. When AWS KMS rotates a key, it generates new key material but retains all previous versions. New encryption operations use the new material. Decryption operations automatically select the correct version based on metadata in the ciphertext. No data needs to be re-encrypted.5
| Rotation Type | How It Works | When to Use |
|---|---|---|
| Automatic rotation | KMS generates new key material on a schedule (e.g., annually) | Default for symmetric encryption keys |
| On-demand rotation | Triggered manually or by policy (e.g., after a suspected compromise) | Incident response, compliance events |
| Re-encryption | Decrypt all data with old key, re-encrypt with new key | When retiring a key entirely or migrating KMS providers |
Legal SaaS scenario: A law firm client terminates their subscription. Your data retention policy requires you to destroy their data after 90 days. If each client matter used a separate DEK, you can crypto-shred — destroy the DEK, rendering the encrypted data permanently unrecoverable without touching the underlying storage. This is faster and more verifiable than attempting to delete every copy of the data across backups, replicas, and caches.6
Key Access Policies: Use vs. Manage
KMS platforms distinguish between two types of access:
- Key users can request encryption and decryption operations but cannot view, export, or delete the key material.
- Key administrators can create, rotate, disable, and delete keys but may not use them for cryptographic operations.
This separation of duties ensures that a compromised application server (which has key-use permissions) cannot delete or export master keys, and an administrator who can manage keys cannot decrypt production data. AWS KMS enforces this through IAM key policies, and HashiCorp Vault uses ACL policies with similar granularity.7
For legal SaaS, this maps directly to professional obligations. The lawyer-equivalent is the ethical wall: one team handles the key (the key administrator, like the conflicts department), another team uses it (the application, like the litigation team). Neither can do the other's job.
Disaster Recovery: The "What If We Lose the Key" Question
If you lose your master key, you lose access to every piece of data it protects. There is no backdoor, no recovery mechanism, no "forgot password" flow. This is by design — it is also terrifying.
Mitigation strategies:
- Multi-region key replication. AWS KMS supports multi-region keys that replicate cryptographic material across regions. If one region fails, the replica can decrypt.8
- Key escrow. Store encrypted copies of key material in a separate, offline system (e.g., a physical HSM in a vault). This is the nuclear option — use only for catastrophic recovery.
- Dual-control procedures. Require multiple administrators to authorise key deletion, preventing a single compromised or rogue admin from destroying keys.
- Deletion scheduling. AWS KMS enforces a minimum 7-day waiting period before key deletion takes effect, providing a window to cancel accidental deletions.9
Real-World Failures
| Incident | What Went Wrong | Impact |
|---|---|---|
| Orrick, Herrington & Sutcliffe (2023) | Attackers accessed personal data of 600,000+ individuals; encryption controls insufficient to prevent exfiltration | $8 million settlement10 |
| Uber (2016) | Encryption keys stored in a GitHub repository alongside code | Exposed 57 million user records; $148 million settlement |
| Adobe (2013) | 3DES encryption with a single key for all 153 million passwords; identical passwords produced identical ciphertext | Enabled pattern analysis; largest credential breach at the time |
What's Next
Episode 30 covers Secrets Management — the closely related problem of protecting API keys, database credentials, and service tokens that your application uses at runtime. If your encryption key is the crown jewels, your API keys are the ring of skeleton keys that opens every door in the building.
Sources & Further Reading
Sources & references
- AWS, AWS KMS Concepts — Envelope Encryption.
- AWS Prescriptive Guidance, Encryption Best Practices for AWS Key Management Service.
- NIST, SP 800-57 Part 1 Rev. 5: Recommendation for Key Management.
- NIST, SP 800-57 Part 1 Rev. 5 — Cryptoperiods, Section 5.3.
- AWS, Rotate AWS KMS Keys.
- AWS Prescriptive Guidance, Key Rotation for AWS KMS and Scope of Impact.
- HashiCorp, Vault Secrets Management Tutorials.
- AWS, Multi-Region Keys in AWS KMS.
- AWS, Deleting AWS KMS Keys.
- Embroker, Law Firm Cyberattacks: Stats and Trends for 2025.
- Thales, NIST 800-57 Key Management Requirements Analysis.
- TerraZone, NIST SP 800-57: Complete Guide to Cryptographic Key Management.