Remove the product names, the acronyms and the vendor marketing from cybersecurity, and a short list of ideas is left. Two of them come back again and again: least privilege and defense in depth.
They sound like textbook filler. They are not. I have worked help desk and desktop support for 20 years. In that time I saw the same two problems many times: an account that could do more than its job needed, and one control that everybody expected to stop everything alone.
This post explains both ideas from the start. It also shows what each idea looks like to an attacker.
Part 1: Least privilege
The principle of least privilege (PoLP): every user, service, process and system gets the access that it needs to do its job, and no more.
The idea is easy to understand. The hard part is to live with it.
An example
A small company has a web application. The application reads customer records from a database and writes new orders to it.
The easy way: the developer makes one database account and gives it db_owner, which is full control of the database. The developer puts the credentials in a config file. The application works.
The least privilege way: the application gets an account with SELECT on the customers table and INSERT on the orders table. It gets nothing else. It has no DROP, no UPDATE on customers and no access to the employee salary table in the same database.
On a normal day, both versions work the same. You only see the difference when something goes wrong.
Why it matters: the blast radius
The web application has a SQL injection vulnerability, and an attacker finds it.
In the first case, the injection point is almost a full database console. The attacker can dump every table and change records. On some database servers, the attacker can also write files to disk and get code execution on the server.
In the second case, the attacker gets the customers table and the ability to insert orders. That is still bad, and it is still a breach that you must report. But it is a contained incident, not one that ends the company.
This is the main point: least privilege does not stop a compromise. It limits what a compromise is worth. Expect that something will be breached one day. Design so that the breach is a bad day, not a disaster.
Where you see it
| Area | Least privilege is ignored | Least privilege is applied |
|---|---|---|
| Windows workstations | All users are local admins | Standard user accounts. Admin rights only for a task. |
| Active Directory | Service accounts in Domain Admins | A dedicated account for each service, with only the rights it needs |
| Cloud (AWS, Azure, GCP) | An IAM role with *:* | Policies that name the specific actions and resources |
| Linux | NOPASSWD: ALL in sudoers | Specific commands allowed for specific users |
| File shares | Everyone: Full Control | Group permissions that match the job function |
| APIs | One token that can do everything | Scoped tokens, short lifetimes, one key for each function |
The attacker’s view
Too much privilege is what turns a foothold into a takeover. These patterns come up in almost every Active Directory attack guide and lab:
- A service account with more rights than it needs. Compromise the service, and you get its rights. If that account is a Domain Admin, the attacker owns the domain.
- A user who is a local admin on their own computer. That is enough to dump credentials from memory, install tools and turn off endpoint protection.
- An API token with no scope. One key leaks in a JavaScript file. Now the attacker can use every endpoint of the API, not only the one that the web page calls.
- Old access that nobody removed. A person moved from IT to sales three years ago and kept every group from the old job. Privilege grows over time when nobody removes it. This is called privilege creep.
From the help desk side, I can tell you how privilege creep happens. A user needs access fast. A ticket gets the user added to a group. Nobody opens a ticket to remove the user later.
The pattern is always the same. The attacker does not need to escalate privileges if the account that they compromised already had too many.
Why it is hard
Least privilege has a real cost. If you pretend that it does not, it fails.
- It takes work to find out what “just enough” access is.
- When you get it wrong, things break, and the help desk gets the call.
- It needs maintenance when roles change.
- When a deadline is close, “give it admin and we will fix it later” always wins.
Do not try to be perfect. Start with the accounts that can reach the most systems, and tighten from there.
Part 2: Defense in depth
Defense in depth: use many independent layers of security controls, so that one failed layer does not cause a compromise.
The usual example is a castle: a moat, an outer wall, an inner wall and a keep. A bank is a more modern example. It has a locked door, a guard, cameras, a vault with a time lock, dye packs in the cash drawers and an alarm to the police. An attacker who defeats one of these still does not have the money.
Layers in a real environment
These are the layers around one web application:
- Network: firewall rules and network segmentation, so that the application server cannot reach the payroll server.
- Edge: a web application firewall (WAF), rate limits and DDoS protection.
- Authentication: a strong password policy and MFA.
- Authorization: least privilege. This is where the two ideas connect.
- Application: input validation, parameterized queries and output encoding.
- Host: patches, EDR, a hardened configuration and no unnecessary services.
- Data: encryption at rest and in transit, and tokenization of sensitive fields.
- Monitoring: logs, alerts, and a person who reads the alerts.
- Recovery: offline backups that you tested.
No single layer is sufficient. Together, they are strong.
An attack through the layers
Follow a phishing email through an environment with layers:
- Email filtering stops most of the campaign. Some messages get through. Layer 1 partly fails.
- User training makes most people report the email. One person clicks. Layer 2 partly fails.
- The link opens a fake login page. The user types their password. Layer 3 fails.
- MFA blocks the attacker’s login with the stolen password. Layer 4 holds.
Now the attacker gets past MFA too, for example with MFA fatigue or a stolen session token. Continue:
- Conditional access flags a login from an unusual country and asks for authentication again. Layer 5.
- The account is a standard user, not an admin, so the attacker cannot install tools. Layer 6. This is least privilege at work.
- The attacker tries to dump credentials, and EDR flags it. Layer 7.
- Network segmentation means that lateral movement reaches only a small part of the network. Layer 8.
- Logs and alerts show the unusual activity, and a person starts an investigation. Layer 9.
Each layer is imperfect. That is the point. You do not build a wall that nobody can break. You add enough friction and enough chances to detect the attacker that you catch them before they reach anything important.
The most important word: independent
Layers only help when they fail independently.
Three products that use the same signature feed are not three layers. They are one layer with three logos. A firewall, an IDS and a VPN concentrator that you manage from one admin portal share one point of failure: that portal. If one stolen credential turns off all three, you had one layer all the time.
When you look at a security stack, ask this question: which single failure stops more than one of these controls? The answer often surprises people.
How the two ideas work together
They are two views of one strategy:
- Least privilege makes each compromise worth less.
- Defense in depth makes the attacker need more compromises.
Least privilege is also one of the strongest layers in defense in depth. It is mostly configuration, not a product that you buy, so it gives a lot of protection for little money.
Both ideas start from the same assumption: something will fail. A user will click. A patch will be late. A vendor will ship a vulnerability. Both ideas design for that fact. They do not hope that it never happens.
Where to start
You can apply both ideas in a home lab, a small business or your own computer.
Least privilege:
- Do not use an administrator account for daily work. Make a standard user account, and elevate only when you need to.
- Find out who has admin rights on what. Remove the rights that nobody can explain.
- Make a list of your service accounts. Check which rights each one really needs.
- Scope your API tokens and rotate them. Use one key for each function, not one key for everything.
- Review access when a person changes roles, not only when they leave.
Defense in depth:
- Turn on MFA everywhere that offers it. Start with email.
- Segment your network. Your IoT devices do not need to talk to your NAS.
- Keep offline backups, and test a restore.
- Send logs to a place where you will see them, and set up some alerts.
- Install patches on a schedule. It is boring, and it is still one of the most valuable layers that you have.
None of this needs a budget. Most of it needs one afternoon.
Closing thought
When you are new to security, it is easy to chase tools: the newest scanner, the best-known EDR, whatever is popular this month. Tools are important, but they only implement principles. The principles stay when the products change.
Learn least privilege and defense in depth until you use them without thinking. Then you can look at an unknown environment and quickly ask better questions: What can this account really do? What happens when this one control fails?
Most of this field is built on that mindset.