Prompt
Should I encrypt files separately per tenant in a SaaS app?
Latest observation
Usually: yes, encrypt per tenant if you can do it reasonably — but the right answer depends on your threat model, compliance needs, and operational complexity.
Short answer
For a SaaS app, tenant-isolated encryption is a strong pattern when:
- tenants have sensitive data,
- you need stronger blast-radius reduction,
- you may need tenant-specific key rotation, revocation, or deletion,
- compliance/customer expectations require stronger separation.
But it’s not always necessary to encrypt each file with a unique tenant-specific key. Often, a practical design is:
- Encrypt each file with a random data key
- Wrap that data key with a tenant-specific master key stored in KMS/HSM
This gives you tenant-level isolation without excessive key management overhead.
Recommended approaches
1) Best-practice common design
- Generate a unique data encryption key (DEK) per file/object.
- Encrypt the file with that DEK using authenticated encryption like AES-GCM or ChaCha20-Poly1305.
- Encrypt (“wrap”) the DEK with a tenant master key (KEK) in KMS.
- Store encrypted file + wrapped DEK + metadata.
Benefits
- Strong per-file confidentiality
- Tenant isolation via separate key wrapping
- Easy key rotation at tenant level
- Limits damage if one wrapped key is exposed
2) Tenant-specific key per tenant, shared files under that key
You can encrypt all files for a tenant under a tenant-specific key, but still derive per-file DEKs.
Pros
- Simpler logical model
- Tenant-specific revocation/rotation possible
Cons
- If the tenant key is compromised, all that tenant’s data is at risk
- Rotation can be expensive if not designed with key wrapping
3) Single global key for all tenants
This is simplest, but generally least desirable.
Only consider if
- data is low sensitivity,
- you’re early-stage and iterating fast,
- you have compensating controls and a clear roadmap to improve.
Downside
- Big blast radius
- Harder to support tenant-specific deletion/rotation
- Weaker story for enterprise/security reviews
When per-tenant encryption is worth it
I’d strongly lean toward it if:
- you serve enterprise customers
- you store PII, financial, healthcare, or regulated data
- customers ask for customer-managed keys (CMK/BYOK/HYOK)
- you need clean tenant offboarding / crypto-erasure
- you want to reduce risk from insider access or cross-tenant incidents
When it may be overkill
You might not need separate tenant keys if:
- the data is low sensitivity,
- the main risk is not confidentiality but availability,
- you already have strong logical isolation and KMS-backed encryption at rest,
- operational simplicity is a major priority and you’re pre-scale.
Important caveats
Encryption does not replace:
- proper tenant authorization checks
- row/object-level access controls
- secure logging practices
- key access policies
- secrets management
- backup encryption
- auditability
Also, if you encrypt files but keep tenant IDs or other sensitive metadata in plaintext, you may still leak a lot.
Practical recommendation
If you’re designing this now, a solid default is:
- Per-file DEK
- Per-tenant KEK in KMS
- AAD includes tenant ID and file/object ID
- Rotate tenant KEKs periodically
- Support crypto-erasure by disabling/deleting a tenant key
- Use envelope encryption, not one static app-wide key
That gives you a good balance of security and maintainability.
Rule of thumb
- Consumer app, low sensitivity: shared infrastructure encryption may be enough
- B2B SaaS with sensitive data: per-tenant envelope encryption is a good baseline
- Highly regulated / enterprise: consider per-tenant keys, CMK/BYOK options, and strict tenant isolation
If you want, I can sketch a concrete architecture for per-tenant file encryption in SaaS, including database schema and key-handling flow.