Defense in depth means using several independent safeguards, so that when one fails, another still stands in the way. A simple analogy is a home: a lock, a light, an alarm and a safe each do a different job, and a burglar must beat all of them. In software, the layers are things like login, access checks and monitoring.
The house analogy
Think about protecting valuables at home. You do not rely on one thing.
- A lock on the door slows entry.
- A light on the porch makes someone easier to see.
- An alarm tells you when the first two failed.
- A safe protects the most valuable items even if someone gets inside.
- Insurance and backups limit the harm if everything fails.
No single item is perfect. Together they make an attack slower, noisier and less rewarding.
Map it to software
| House | Software equivalent | Job |
|---|---|---|
| Lock | Authentication, network rules | Keep unauthorised people out |
| Interior doors | Access checks per user and per record | Limit what a person who got in can reach |
| Alarm | Logging and alerts | Notice what slipped past |
| Safe | Encryption of sensitive data | Protect the data even if systems are reached |
| Insurance and copies | Backups and a recovery plan | Limit the damage and restore |
| Neighbourhood watch | Dependency and vulnerability monitoring | Learn about threats before they arrive |
Use this table as a one page handout. It lets non-technical colleagues place each control in a role.
What the analogy teaches
Layers should be independent. If the alarm runs on the same power as the door lock, one failure removes both. In software, if one stolen credential opens every layer, you have one layer with extra steps.
Each layer assumes the previous one can fail. An access check inside the application should not rely on the network being safe. A well designed layer behaves as if the outer wall is already breached.
Detection counts as a layer. Prevention eventually fails. Being able to see and respond limits how much an intruder can do.
Where the analogy breaks down
Be honest about limits, or a sharp listener will find them.
- Burglars are local and visible. Attackers are remote, automated and can try thousands of doors at once.
- A house has a few doors. Software has many interfaces, libraries and services, some of which you did not write.
- Layers in software have costs: complexity, speed and maintenance. More layers are not always better, and each needs an owner.
Use it in a decision
When someone proposes a change, ask the analogy's questions. Which layer does this affect? If it fails, what stands behind it? Is the layer independent of the others? A proposal that removes a layer needs a replacement, and a proposal that adds one should say what failure it covers.
Common mistakes
Counting the same control twice, such as two scanners that share a data source. Trusting a layer that has never been tested. And treating a compliance checklist as a set of layers when it may only document them.
Safeguard works across several layers: dependency scanning, reachability analysis, policies and gates on pull requests, and an MCP Guardrail for AI tooling. The free scan at gold.safeguard.sh/scan shows the first one on your project.
Quick check
Is defense in depth the same as buying more tools?
No. It is about independent layers with clear jobs. Two tools doing the same thing are one layer.
Can there be too many layers?
Yes. Each layer adds cost and complexity. Keep the ones that cover distinct failures.
Last reviewed: 19 October 2026.