Least Privilege, Defense in Depth and Secure Defaults
Three foundational principles shape almost every secure design: give each subject only what it needs, never rely on a single control, and ship systems in a secure state. This lesson explains each with examples.
Learning outcomes
After completing this lesson, you will be able to:
- Explain least privilege, defence in depth and secure defaults.
- Identify violations of these principles in a design.
Least privilege
The principle of least privilege grants users, processes, services and devices only the access they need to perform their function, and only for as long as they need it. Examples include separate standard and administrator accounts, services that run under dedicated low-privilege accounts, just-in-time elevation for administrators, and applications that request only the permissions they use.
Least privilege limits the damage from compromised accounts, malware and mistakes: an attacker who takes over a low-privilege account cannot do as much harm. Need to know applies the same idea to information. Threat modelling during design identifies the privileges each component truly needs.
Least privilege and need to know are related but not identical. Least privilege limits what a subject can do, such as whether it may install software or change a firewall rule. Need to know limits what information a subject may see, even among people with the same clearance or role. Two investigators with the same clearance may each see only the case files assigned to them, because neither needs the other's cases for their work.
Least privilege also has a time dimension. Standing privileges, which are granted permanently, are available to an attacker at any moment the account is compromised. Just-in-time access grants elevated rights only when a task requires them, for a limited period and often with approval, and removes them automatically afterwards. An administrator who needs to restart a production database requests elevation for one hour, performs the task and then returns to a standard account, so a stolen password is far less useful to an attacker during the rest of the day.
The main practical difficulty is that privileges tend to grow. Developers grant broad permissions to make something work quickly, users accumulate access as they change roles, and nobody removes rights that are no longer used. Least privilege is therefore maintained, not just designed, through periodic access reviews and tools that report unused permissions.
Least privilege or need to know?
Defence in depth
Defence in depth (layered defence) places multiple, independent controls between threats and assets so that the failure of one does not expose the asset. Layers span policies and training, physical security, perimeter and internal network controls, host hardening, application security and data protection, and combine preventive, detective and corrective controls.
Diversity strengthens layering: using different technologies or vendors means one vulnerability or misconfiguration does not defeat every layer. Each layer should be meaningful on its own, not a duplicate of another.
Layers that share a single point of failure are not independent. If every layer authenticates against the same directory using the same administrator account, an attacker who compromises that account defeats them all at once. Independence is therefore part of the design, for example by using separate credentials and management networks for security tools.
The following diagram shows the layers a phishing attack must pass.

Are the layers independent?
A phishing email meets the layers
A phishing email carrying malicious software is sent to an employee. How does each layer of defence get a chance to stop it?
The email first meets the email gateway, which may filter it. If it gets through, awareness training may lead the user to report it. If the user opens it, endpoint protection may block the payload, and application allowlisting may stop it from running. If it still runs, least privilege limits what it can reach, network segmentation stops it spreading to servers, monitoring detects its unusual connections, and encrypted, offline backups allow recovery.
Each layer is imperfect, but the attacker must defeat all of them, while the defender needs only one to succeed.
Secure defaults
Secure defaults means a system is secure in its out-of-the-box configuration. Unneeded services and ports are disabled, there are no default or blank passwords, encryption is on, permissions are restrictive and logging is enabled. Reducing security should require a deliberate action, ideally with a warning. When vendors do not ship secure defaults, hardening guides and baselines such as CIS Benchmarks fill the gap.
Defaults matter because most systems are never reconfigured. Internet-connected cameras and routers shipped with the same default administrator password on every unit have been taken over in very large numbers by automated malware that simply tries the published defaults. A secure default design gives each device a unique password or forces the owner to set one before the device works. The same principle applies to software that organisations build: a new storage bucket should be private unless someone explicitly makes it public, and a new user should start with no access rather than with a broad default group.
Secure defaults are closely linked to fail-safe defaults, a classic design principle stating that access decisions should be based on explicit permission rather than exclusion. A rule set that denies everything unless it is specifically allowed fails securely when an administrator forgets a case, whereas a rule set that allows everything unless it is specifically denied exposes whatever was forgotten.
Secure out of the box
Applying the principles
A web application connects to its database using the database administrator account, so that developers do not have to manage permissions. Which principle is violated and what is the risk?
This violates least privilege. If an attacker exploits a SQL injection flaw, they inherit full administrative rights over the database and can read, alter or drop every table, or even run operating system commands. The application should use a dedicated account with only the permissions it needs, such as reading and writing specific tables, which turns a total compromise into a limited one.
Why does diversity strengthen defence in depth?
Show answer
Different technologies or vendors at each layer mean one vulnerability or misconfiguration cannot defeat every layer.
Exam Tips
Remember for the exam
- Least privilege limits the blast radius of a compromise.
- Defence in depth uses independent, diverse layers.
- Secure defaults make the safe choice the easy choice.