SECURITY ENGINEERING · PART 0 · START HERE · BASICS · 6 OF 229

Security Principles: Least Privilege and Zero Trust

The handful of principles behind every secure design, each shown on one online shop: least privilege, defense in depth, zero trust, secure by default, separation of duties, fail safe, keep it simple and open design. Plus authentication, authorization and accounting (AAA), non-repudiation, and how to use the principles to review any system in an interview.

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 9
  9. 10
  10. 11
  11. 12
  12. 13
  13. 14
  14. 15
  15. 16
  16. 17
  17. 18
  18. 19
  19. 20
  20. 21
  21. 22
  22. 23
  23. 24
  24. 25
  25. 26
  26. 27
  27. 28
  28. 29
  29. 30
  30. 31
  31. 32
  32. 33
  33. 34
  34. 35
  35. 36
  36. 37
  37. 38
  38. 39
  39. 40
  40. 41
  41. 42
  42. 43
  43. 44
  44. 45
  45. 46
  46. 47
  47. 48
  48. 49
  49. 50
  50. 51
  51. 52
  52. 53
  53. 54
  54. 55
  55. 56
  56. 57
  57. 58
  58. 59
  59. 60
  60. 61
  61. 62
  62. 63
  63. 64
  64. 106
  65. 107
  66. 108
  67. 109
  68. 110
  69. 111
  70. 112
  71. 113
  72. 114
  73. 115
  74. 116
  75. 117
  76. 118
  77. 119
  78. 120
  79. 121
  80. 122
  81. 123
  82. 124
  83. 125
  84. 126
  85. 127
  86. 128
  87. 129
  88. 130
  89. 131
  90. 132
  91. 133
  92. 134
  93. 135
  94. 136
  95. 137
  96. 138
  97. 139
  98. 140
  99. 141
  100. 142
  101. 143
  102. 144
1 / 13

Press play to hear the narration, or step through at your own pace.

Key takeaways

  • Least privilege
  • defense in depth
  • zero trust
  • secure by default
  • separation of duties
  • fail safe
  • simple
  • open

Notes

1 · Least privilege

First, least privilege. Every person and every program gets only the access its job needs, and nothing more. The shop's web application can read and write orders, but it cannot drop tables. Support staff can look up one customer at a time, not export them all. Access is removed when the need ends. In episode three, one cloud role that could read every bucket turned a small break-in into a large one. Least privilege limits the blast radius.

Least privilege
  • the web app can read and write orders: not drop tables
  • support staff see one customer at a time, not an export
  • a build job can push to one registry, nothing else
  • access is removed when the need ends
  • limits the blast radius

2 · Defense in depth

Second, defense in depth. Never rely on one wall. The shop has rate limits at the edge, a database that is not reachable from the internet, strong logins, an application that checks every input, encrypted data and alerts on unusual reads. The layers must be independent. Two locks that open with the same key are really one lock. Each layer assumes the one before it has already failed.

Defense in depth
  • edge: WAF and rate limits
  • network: database is private
  • identity: MFA, least privilege
  • application: input checked
  • data: encrypted at rest
  • monitoring: alerts on odd reads
  • layers must be independent: two locks, two different keys

3 · Zero trust

Third, zero trust. The old model was a castle: a hard shell and a soft inside. Once you were past the firewall or the VPN, everything trusted you, which is exactly what an attacker with one stolen laptop wants. Zero trust removes the idea of a trusted inside. Every request is checked: who are you, is your device healthy, and are you allowed to do this, right now? The slogan is never trust, always verify.

Zero trust
  • old model: a hard shell, a soft inside. Past the VPN, everything trusts you
  • zero trust: every request is checked. Who are you? Is the device healthy? Are you allowed this, right now?
  • never trust, always verify

4 · Secure by default

Fourth, secure by default. The safe setting is the one you get without doing anything. A new storage bucket is private. A new account requires a second factor. A new service has no open ports until someone asks for one. Debug mode is off in production. People are busy and accept defaults, so the default has to be the safe choice, and an insecure choice should need an explicit, visible decision.

Secure by default
  • a new bucket is private
  • a new account needs MFA
  • a new service has no open ports until you ask
  • debug mode is off in production
  • insecure choices need an explicit, visible decision

5 · Separation of duties

Fifth, separation of duties. No single person can complete a dangerous action alone. Code needs a second person's review before it merges. Whoever requests a refund cannot also approve it. Nobody can both change the audit logs and be audited by them. This stops honest mistakes and fraud, and it also means an attacker with one stolen account still cannot finish the job without a second.

Separation of duties
  • code needs a second person's review before it merges
  • the person who requests a refund cannot approve it
  • no one both changes the logs and is audited by them
  • stops mistakes and fraud, and a single stolen account

6 · Fail safe

Sixth, fail safe, also called fail closed. When something breaks, the answer is no. If the permission check throws an error, the request is denied. If the login service cannot be reached, nobody gets in. The last rule in a firewall list denies everything not already allowed. Attackers deliberately cause errors to see what happens, so a bug should lock the door, never open it.

Fail safe (fail closed)
  • permission check throws an error: deny the request
  • cannot reach the login service: nobody gets in default rule at the end of a firewall list: deny all
  • a bug should lock the door, not open it

7 and 8

Seventh, keep it simple. Every feature, open port and extra setting is more attack surface and more to get wrong, so remove what you do not need. Eighth, open design. Assume attackers know exactly how your system works. Its safety must rest on secret keys, never on a secret method. That is why engineers use published, widely tested cryptography, and never invent their own. Security through obscurity fails the day someone looks.

Simple and open
  • keep it simple: every feature, port and setting is more attack surface. Remove what you do not need
  • open design: assume attackers know how it works. Safety rests on keys, not secrecy
  • no home-made cryptography

AAA

These principles sit on three questions, known as AAA. Authentication: who are you? Authorization: what are you allowed to do? Accounting: what did you do, recorded in logs that cannot be quietly changed. People confuse the first two all the time. Logging in is authentication. Being blocked from another customer's order is authorization. A fourth idea, non-repudiation, means there is proof of an action that its author cannot later deny, such as a digital signature.

AAA
  • authentication: who are you? password, passkey, MFA
  • authorization: what may you do? roles and permissions
  • accounting: what did you do? logs that cannot be changed
  • non-repudiation: proof you cannot later deny it

Using them

Here is how to use them. Turn each principle into a question and ask it of any design. Who can reach this, and do they all need to? If this layer fails, what stops the attacker next? What does this component trust without checking? What happens on an error? What does a new user or resource get by default? Can one account do the whole dangerous thing alone? Six questions, and you can review a system you met ten minutes ago.

Review questions
  • who can reach this, and do they all need to?
  • if this layer fails, what stops the attacker next?
  • what does it trust without checking?
  • what happens on an error?
  • what is the default?
  • can one account do it all?

Common mistakes

Mistakes. Giving everyone admin for now, which becomes forever. Never removing access when people change roles. Trusting anything that comes from the internal network. Building layers that share one password. Writing error handling that lets the request through. Relying on a secret design instead of secret keys. And mixing up authentication with authorization, so a logged-in user can read data that belongs to someone else.

Avoid these
  • admin for everyone, "for now"
  • access that is never removed
  • trusting the internal network
  • layers that share one password
  • errors that let requests in
  • secret designs instead of keys
  • mixing up authn and authz

Say it like this

In the interview: I start with least privilege to limit blast radius, and defense in depth so one failure is not a breach. Zero trust, so nothing is trusted just for being inside the network. Secure defaults, separation of duties for dangerous actions, and failing closed on errors. And I keep designs simple and open, relying on standard cryptography and protected keys rather than secrecy. Then give one example from something you built.

In the interview
  • "Least privilege to limit blast
  • radius, defense in depth so one failure is not a breach, zero
  • trust so nothing is trusted for being inside, secure defaults, separation of duties, and fail
  • closed. Then simple, open
  • designs with standard crypto."

Interview questions

Q1What is the principle of least privilege?

Every user, service and process gets only the minimum access needed for its task, for only as long as it is needed. It limits the damage (blast radius) when an account or component is compromised.

Q2What is zero trust?

A model with no trusted internal network: every request is authenticated, authorised and checked against context such as device health, regardless of where it comes from. Summed up as never trust, always verify.

Q3What is the difference between authentication and authorization?

Authentication proves who you are (password, passkey, MFA). Authorization decides what you are allowed to do (roles and permissions). A logged-in user reading another user's data is an authorization failure.

Q4What does fail safe or fail closed mean?

When a security check errors or a dependency is unavailable, the system denies access by default rather than allowing it, so failures and deliberately caused errors cannot be used to bypass controls.

Q5What is separation of duties?

Splitting a sensitive action across more than one person or role, for example code review before merge or separate request and approval for payments, so no single person or stolen account can complete it alone.

Q6What is secure by default?

Systems ship with the safe configuration already on: private storage, MFA required, no open ports, debug off. Insecure options require an explicit decision, because most users keep defaults.

Q7Why is security through obscurity a bad idea?

It depends on attackers never learning how the system works, which fails as soon as someone reverse engineers it or a detail leaks. Open design assumes the method is known and relies on protected keys instead.

Q8What is AAA in security?

Authentication (who are you), authorization (what may you do) and accounting (a record of what you did). Together with tamper-resistant logs they support non-repudiation, where an action cannot later be denied.