Skip to content

Interview question · Security Foundations & Threat Modeling

Explain least privilege and defence in depth with an example where one layer failing does not cause a breach.

Definitions take ten seconds. The interviewer wants a worked failure: which layer broke, which one held, and why they did not break together.

easyEssentialNewPreparation tags: Amazon, Google, MetaUpdated Nov 2026

TL;DR: Least privilege grants each user, service or agent only the access its task needs, so a compromise reaches little. Defence in depth layers controls that fail for different reasons, so one failure is not a breach. Example: a SQL injection in a reporting endpoint is the failed layer; a database account that can only read two reporting views, and an egress rule that blocks the database host from the internet, are the layers that hold.

How to approach it

Define both principles in one sentence each, then spend the time on a single concrete incident. Walk it forward: the layer that failed, what the attacker could then reach, and which control stopped them. Close by explaining why the surviving layers did not share the failed layer's weakness.

A strong answer

FIG · DEFENCE IN DEPTH · ONE LAYER FAILS, NO BREACH
A SQL injection in a reporting endpoint, contained by the layers behind it

SQL injection

the failed layer

Read-only DB role

reporting views only

Network policy

no outbound from DB

Detection

unusual query shapes

Least privilege

Each layer grants only what the task needs

narrow roleno egressshort-lived creds

Definitions. Least privilege (Saltzer and Schroeder, 1975): every component operates with the least set of privileges needed for the job. Defence in depth: more than one control stands between an attacker and an asset, and the controls fail independently.

Worked example. A reporting service has a search box. A developer builds one query with string concatenation, and an attacker finds the SQL injection.

LayerStatusWhy it matters
Parameterised queriesFailed on one endpointThe bug exists
Database account for reportingHeldIt can read two reporting views and nothing else; no access to credentials or payment tables
Network egressHeldThe database host cannot open connections to the internet, so out-of-band exfiltration fails
Query timeouts and row limitsHeldBulk extraction through the page is slow and capped
Anomaly alertingDetectedUnusual query shapes from one session page the on-call engineer

The bug was real and the damage was a handful of reporting rows, because the other layers were built on different mechanisms: database permissions, network rules, resource limits and monitoring. None of them depended on the application code being correct.

The AI version. An email assistant is fooled by an injected instruction in a message. That layer, the model resisting injection, has failed. Least privilege says the assistant's token can read this user's inbox and send only to addresses in the user's organisation. Defence in depth adds an outbound allowlist enforced in the send tool and approval for any external recipient. The injection succeeds and the exfiltration does not.

What makes layers independent. Different mechanisms, different code paths and different owners. Two classifiers from the same vendor are not two layers in any useful sense; a classifier plus an authorization check in code are.

What interviewers probe next

  • "Least privilege makes engineers' lives harder. How do you get adoption?" Make the narrow path the easy path: role templates per task, automatic short-lived credentials, and fast approval for exceptions.
  • "How do you know your layers are independent?" Ask what single bug, credential or outage would defeat two of them at once; if one exists, they are one layer.
  • "Which layer would you build first?" The one closest to the asset that does not depend on the model or the application being correct, usually authorization and scoped credentials.

What if?

What if · interview follow-ups

Hold your answer as the constraints change

A reporting service needs to read sales data and produce monthly PDFs for managers, and currently uses the database owner account.

  1. Start here

    What is least privilege?

How it's scored

Weak: Defines both terms and lists controls with no example of one failing.

Hire: Walks one realistic failure and shows which scoped permission or second layer limited it.

Strong Hire: Explains why the layers fail independently, covers detection as well as prevention, and applies the same reasoning to an agent.

Common mistakes

  • Calling two filters of the same kind "defence in depth".
  • Granting broad roles "temporarily" with no expiry.
  • Forgetting detection, so a contained attack goes unnoticed.
  • Giving agents every tool in case they need it.
You just read a free answer. Every topic opens its first 5 answers to anyone. Sign in and the count per topic goes to 10, and we keep track of how far you get in every topic.Google sign-in · free · no payment details
HOW DID IT GO?
0
READING SIGNED OUT

Signing in doubles your free answers, from 5 to 10 per topic, and the site starts remembering you: mastery per topic, bookmarks, and a next-focus recommendation. Free, no card.

Sign in free
UP NEXT ON YOUR JOURNEY
DISCUSSION · 0

No comments yet. Share a correction or a different way to answer it.