Q&A-1Design defense in depth for an internet-facing SaaS platform.
Answer
Assumptions first: multi-tenant SaaS on a public cloud, tenants mutually untrusted, you own the app and the cloud accounts but not the internet. Target 99.95% monthly availability, RTO 1 hour, RPO 5 minutes for tenant data.
The answer: Defense in depth means every layer assumes the layer in front of it already failed, and each layer fails for a different reason. If two controls trip on the same signal, you have one control, not two.
Edge. Anycast CDN absorbs volumetric L3/L4 (SYN floods) before it reaches your origin: Shield Advanced or Cloudflare. L7 WAF with rate-based rules handles crude floods and known signatures. WAF cannot authorize: it sees a URL and headers, not whether tenant A may read tenant B's object. Lock the origin so it only accepts traffic from the CDN (shared secret header plus a security group restricted to CDN ranges), or the attacker bypasses the WAF by hitting the origin IP directly.
Identity. OIDC with 15-minute access tokens and refresh rotation; service-to-service mTLS with SPIFFE identities; workloads get cloud IAM roles, never static keys.
Per-request authz at the service. Re-check subject-device-workload-resource on every call; the gateway's decision is not trusted downstream. Policy in OPA or Cedar, deny by default.
Segmentation. Separate cloud accounts for control plane, data plane, CI/CD, and logging. Tenant isolation via row-level tenant_id plus a per-tenant KMS CMK.
Data. Envelope encryption: per-tenant CMK, data keys cached ~5 minutes. The key policy grants decrypt to a key-broker role, not the app role, so a compromised app cannot decrypt other tenants.
Egress. Default-deny, allowlisted through a proxy.
Supply chain. Signed artifacts (cosign/Sigstore), SLSA provenance, admission controller rejects unsigned images.
Telemetry. Logs shipped to a separate account with write-only credentials and S3 Object Lock.
Recovery. Backups in a separate account, cross-region, immutable; restore tested on a schedule.
| Layer | Control | Stops | Doesn't stop |
|---|---|---|---|
| Edge | Anycast + WAF | Volumetric floods, known signatures | Cross-tenant authz |
| Identity | Short tokens, mTLS | Stolen long-lived creds | Replay of a live token |
| Service | Per-request authz | Cross-tenant reads | Compromised policy engine |
| Data | Per-tenant CMK | Bulk decrypt | App-role key grant mistakes |
| Recovery | Isolated immutable backups | Ransomware deletion | Region-wide provider failure |
Worked trace: tenant A's token tries to read tenant B's object:
- 2M rps SYN flood hits anycast; absorbed at the edge, never reaches origin.
- L7 request with a valid JWT passes the WAF: it can't read the tenant binding.
- Gateway validates signature and expiry; passes.
- Service authz sees subject tenant A, resource owner tenant B → 403, audit event.
- Even if step 4 were skipped, KMS decrypt of tenant B's CMK fails because the app role has no grant: a second, independent failure.
Arithmetic for the key cache: 10,000 tenants, KMS default quota 5,500 req/s per account per Region. Calling KMS per request saturates at 5,500 rps. Caching data keys for 5 minutes drops it to 10,000/300 ≈ 33 calls/s.
Failure modes and detection:
- Origin not locked to the CDN → direct-to-origin bypass. Detect: origin access logs with source IPs outside CDN ranges.
- Long-lived tokens without sender-constraining → replay. Detect: same token from two ASNs.
- Backups in the same account → admin compromise deletes both. Detect: alarm on backup-vault deletion.
- Over-broad KMS key policy → one compromised role decrypts all tenants. Detect: CloudTrail Decrypt volume per principal.
When not to add a layer: per-tenant CMKs cost ~$1/key/month and add a KMS round trip; below a few hundred tenants a shared CMK with per-tenant data keys is fine. Don't put business logic in WAF rules: latency and false positives. Single-tenant deployments gain nothing from per-tenant key separation.
Measure mean time to contain, blast radius (tenants affected per incident), and tested path interruption, not tool count.
Curated: · Written: · Reviewed:
Log in free to save your progress and keep bookmarks and notes for a quick revision before your interview.