Defense in depth
Defense in depth means protecting a system with several independent layers of controls, so that no single failure exposes it. A phished password is stopped by multi-factor authentication; a compromised service can’t reach the database because the network doesn’t allow it; data stolen anyway is encrypted with keys the attacker doesn’t have; and the whole thing is detected because unusual access raised an alert.
The idea is old and military in origin. What matters in practice is that the layers are independent: two controls that fail for the same reason are one control.
Diagram
Section titled “Diagram”- The edge filters malicious and excessive traffic before it reaches anything.
- Identity controls require strong authentication and grant only the access needed.
- Network segmentation limits what a compromised component can reach.
- The application validates input and checks authorization on every request; the data layer encrypts and minimizes what's stored.
- Detection spans every layer, so an attacker who gets through some is still noticed and contained.
The layers
Section titled “The layers”| Layer | Controls | What it protects against |
|---|---|---|
| People and process | Training, secure development lifecycle, change control | Phishing, unsafe changes |
| Edge | Web application firewall, DDoS protection, rate limiting | Common web attacks, floods |
| Identity | MFA, single sign-on, least privilege, just-in-time admin access | Stolen passwords, excessive access |
| Network | Segmentation, private endpoints, egress control, mutual TLS | Lateral movement, data exfiltration |
| Workload | Hardened images, patching, runtime protection | Exploited vulnerabilities |
| Application | Input validation, authorization per request, dependency scanning | Injection, broken access control |
| Data | Encryption at rest and in transit, tokenization and masking, backups | Data theft, ransomware |
| Detection and response | Central logging, alerts, incident runbooks, tested restores | Attacks that get through everything else |
Defense in depth and zero trust
Section titled “Defense in depth and zero trust”Zero trust is one way of applying defense in depth: it removes the assumption that anything inside the network is trusted and checks identity and authorization on every request. A “castle and moat” design, with one strong perimeter and a trusted interior, isn’t defense in depth at all, however strong the moat.
Designing for it
Section titled “Designing for it”- Assume breach of each layer in turn, and ask what stops the attacker next. A threat model of the most important data flows is the practical way to do this.
- Check independence. If one admin account can disable the firewall, delete the logs and read the database, the layers share a single point of failure.
- Limit the blast radius: separate accounts or subscriptions per environment and workload, separate credentials per service.
- Protect the protections: logs written where the systems they monitor can’t delete them, backups that the production credentials can’t encrypt or delete.
- Balance cost and friction. Every layer has a cost to users and teams. Put the strongest layers around the most valuable data.
- No single mistake or vulnerability leads to a full breach.
- Time to detect and respond before an attack succeeds.
- More controls to operate and pay for.
- Layers can give false comfort if each one is assumed to be someone else’s safety net and none is maintained.
Common pitfalls
Section titled “Common pitfalls”- Layers that share a failure mode, such as one identity provider with no MFA guarding every control.
- No detection layer, so attacks that get through are discovered months later.
- Backups reachable with production credentials, which ransomware deletes first.
- Strong perimeter, flat interior.
Related patterns
Section titled “Related patterns”- Zero trust architecture
- Threat modeling
- Secrets management
- Designing for failure, the same principle applied to reliability
Written and edited by Abhinav Taduka, enterprise software architect.
New pages are added regularly. Follow Abhinav on LinkedIn to see them first.