Defense in Depth
Defense in Depth: cybersecurity principle of stacking independent layers of protection so that breaching one layer is not enough to compromise the whole system.

Defense in Depth is a cybersecurity principle that consists of stacking several independent layers of protection rather than relying on a single line of defense. The core idea: no security control is infallible, so a system's security should never rest on a single point. If an attacker gets around one layer, they still have to get through several others before reaching critical data.
Technical definition
The principle of independent layers
The key word is independent. Two layers that share the same mechanism or the same implementation do not provide defense in depth: the same flaw can compromise both at once. A good strategy stacks heterogeneous layers: a WAF at the CDN level, filtering rules at the reverse proxy, validation code in the application, and constraints in the database. Each layer is built on a different technology stack, with different failure modes.
The medieval castle analogy
The classic metaphor is the fortified castle. The attacker has to get past the moat (slowdown), the portcullis (first physical control), the outer bailey (crossfire zone), the inner drawbridge (second control) and the keep (final fallback). None of these obstacles is impassable on its own, but together they make an attack costly, slow and detectable. Defense in Depth applies the same logic to information systems.
Current challenges
Pushing controls as low in the stack as possible
An effective implementation places each security control at the lowest level where it can be enforced. URL filtering belongs in the reverse proxy (Nginx, Envoy), not in application code. Rate limiting belongs in the router or the CDN. Encryption belongs in the storage layer, not in the code. This logic naturally produces an architecture where each layer has a clear responsibility, and where security is not an "application" problem to be solved with business code.
Complexity as the enemy
Defense in Depth has a trap: it can degenerate into a pile of redundant, poorly coordinated controls that add complexity without adding security. Every added layer is extra attack surface and one more component to maintain. A good strategy favors a few well-designed, well-tested layers over a long list of cosmetic controls. The ultimate test: each layer should be able to produce its own incident detection and its own audit log.
Practical applications
Securing a WordPress site
Rather than handing everything to an application-level security plugin, a Defense in Depth approach to WordPress stacks: Nginx rules that block dangerous patterns before PHP is even loaded, HTTP headers at the server level, a strict CSP to contain injections, a read-only filesystem to prevent code uploads, auditing of Composer dependencies, and an integrity check of WordPress core on every deployment. I describe this approach in detail in my article on securing WordPress with Infrastructure as Code.
Zero Trust and Defense in Depth
Modern Zero Trust architectures are a radical application of Defense in Depth: every interaction between two components (service to service, user to service, process to process) must be authenticated and authorized, whatever network zone it happens in. The underlying principle is the same: trust no perimeter, and stack controls at every boundary.
Frequently Asked Questions
Where does the Defense in Depth concept come from?
The concept is military before it is digital. It describes a doctrine of territorial defense that does not rely on a single front line but staggers several lines of defense, so that breaking through the first one does not cause a general collapse. The NSA adopted and formalized the term for cybersecurity in the 1990s, and it has since become a pillar of the NIST and ISO 27001 standards.
What are the typical layers of a Defense in Depth strategy?
A classic implementation stacks at least: (1) network perimeter (firewall, DDoS protection, CDN), (2) transport layer (TLS, VPN, segmentation), (3) application server (OS hardening, Nginx/Apache rules, WAF), (4) runtime (sandbox, disable_functions, process isolation), (5) application (input validation, authentication, authorization), (6) data (encryption at rest, access control, auditing), (7) governance (training, security policy, incident response).
How do you apply Defense in Depth to a web application?
In practice, it means not entrusting all of your security to a single tool (for example a WordPress plugin or a cloud WAF). Each layer must have its own responsibility, and each layer must keep working even if the previous one has been compromised. A good test: if my security plugin disappeared tomorrow, what would still protect my site? If the answer is "nothing," the strategy is not Defense in Depth: it is a single point of failure.