open atlas
↑ Back to track
Security Foundations SECF · 00 · 01

Why every engineer needs a security foundation

Security is a way of thinking, not a checklist. This lesson frames the whole cybersecurity cluster around Shostack's four questions, pins down threat vs vulnerability vs risk, and maps how foundations, red, blue, and cloud feed the appsec track you already know.

SECF Junior ◷ 14 min
Level
FoundationsJuniorMiddleSenior

You ship a feature that lets users upload a profile picture and pass it through an image-resizing service that fetches the file by URL. Code review loves it: tidy handler, validated content-type, nice tests. Three weeks later someone posts http://169.254.169.254/latest/meta-data/iam/security-credentials/ as their “image URL” and your server happily fetches it — handing back the IAM credentials your EC2 instance uses to read every bucket you own. Nothing was broken. Every line did exactly what it was told. The gap was that nobody asked the security question: what can an attacker make this code do that I didn’t intend? That question — not any single tool or checklist — is what this whole cluster teaches you to ask reflexively.

By the end of this lesson you’ll be able to frame any system you build with the four security questions, tell threat from vulnerability from risk without hesitating, and place the offensive, defensive, cloud, and appsec tracks on one mental map.

Security is a way of thinking, not a feature

The most expensive misconception a competent engineer carries into security is that it’s a layer — a WAF here, a scanner there, a checkbox in the deploy pipeline. It isn’t. Security is an adversarial frame of mind you apply to everything you design. A functional engineer asks “does this work when used correctly?” A security-competent engineer also asks “what happens when someone uses it incorrectly on purpose?” That single extra question is the difference between code that passes review and code that survives contact with the internet.

Adam Shostack, who ran threat modeling at Microsoft for years, distilled the whole discipline into a four-question spine that scales from a sketch on a whiteboard to a multi-region platform:

  1. What are we building? Draw the system. Where does data enter, where does it cross a trust boundary (browser → server, service → database, your code → a third-party API), and where does it leave?
  2. What can go wrong? For each component and each boundary, enumerate how an attacker could abuse it. The image-resizer fetching an attacker-chosen URL is a “what can go wrong” that the “what are we building” step makes visible.
  3. What are we going to do about it? Choose mitigations — and choosing to accept a risk, or to transfer it (insurance, a vendor’s SOC 2), counts as a valid answer too. Not every risk gets a control.
  4. Did we do a good job? Verify the mitigations actually hold. Pentest, review, monitoring. A control you never tested is a control you don’t have.

You can run these four questions in five minutes against a single endpoint or over two days against a payments platform. The depth scales; the questions don’t change. Internalizing them is the actual goal of “having a security foundation” — everything else in the cluster is detail hung on this frame.

Threat, vulnerability, risk: three words people use interchangeably and shouldn’t

Imprecise vocabulary is how security conversations go in circles. These three words name three different things, and a senior engineer keeps them crisp because the distinction drives what you actually do.

  • A threat is a who and a what they want — a potential actor and a harmful action they could take. “A bored authenticated user who wants to read other people’s invoices.” Threats exist whether or not your system is flawed; they’re a property of the world, not your code.
  • A vulnerability is a flaw in your system that a threat could exploit. “The invoice endpoint queries WHERE id = ? without also checking owner_id.” Vulnerabilities are a property of your code and config — they’re the part you control.
  • Risk is the combination: how likely is this threat to hit this vulnerability, and how bad is the impact if it does? Risk is what you prioritize on, because you can’t fix everything. A vulnerability nobody can reach and that leaks nothing valuable is low risk; the same flaw on your auth path is a five-alarm fire.

A common shorthand: risk ≈ likelihood × impact, where a vulnerability raises likelihood and the value of what’s behind it raises impact. The practical payoff is triage. You don’t patch “the most vulnerabilities”; you reduce “the most risk.” That’s why a typo in an error message (a vulnerability — information disclosure) sits below an unauthenticated admin endpoint even though both are technically flaws.

TermWhat it isWho owns itInvoice example
ThreatAn actor + a harmful goalThe world (you can’t delete it)A user who wants to read others’ invoices
VulnerabilityA flaw the actor can exploitYou (your code/config)Query lacks an owner_id check
RiskLikelihood × impact of the pairYou (it’s what you triage)High: trivial to exploit, leaks PII
Why this works

Why obsess over the wording? Because the three words map to three different jobs, and conflating them sends fixes to the wrong place. You can’t eliminate a threat — bored users and ransomware crews exist regardless of your code — so trying to “remove the threat” is wasted effort. You can remove a vulnerability, and you manage risk by deciding which vulnerabilities are worth the cost of fixing now. When a stakeholder says “what’s our risk here?” they’re asking a likelihood-times-impact question, and answering with a list of vulnerabilities (or worse, a list of threats) is why so many security reviews feel like they generate noise instead of decisions.

Defense in depth: assume every layer fails

The fourth load-bearing idea is that no single control should be all that stands between an attacker and the prize. Defense in depth means layering independent controls so that the failure of any one of them doesn’t end the game. Your WAF misses a payload → input validation catches it. Validation has a gap → parameterized queries neutralize the injection anyway. Someone steals a token → short token lifetimes and revocation limit the blast radius. Each layer assumes the layer in front of it will eventually fail, because in production it eventually does.

This is the practical reason “what are we going to do about it?” rarely has a one-line answer. The image-resizer story is a defense-in-depth lesson: the fix isn’t one thing but several — validate that the URL resolves to a public address, block the link-local metadata range at the network layer, give the instance a least-privilege role so stolen credentials are nearly worthless, and detect the anomalous outbound request. Any one of those alone is a single point of failure.

How the cluster fits together

With the mindset in place, the rest of the cybersecurity cluster is just where you point it. Foundations is this frame — the four questions, the vocabulary, threat modeling — and everything downstream inherits it. From there the field splits into roles defined by which question they live in:

  • Red (offensive) lives in what can go wrong. Red teams and pentesters think like attackers on purpose, finding the vulnerabilities your design missed. Their output is “here’s what an adversary can actually do.”
  • Blue (defensive) lives in what are we going to do about it and did we do a good job. Detection, monitoring, incident response, hardening. Their output is “we caught it, contained it, and it won’t work again.”
  • Purple is the deliberate collaboration of the two: red shows blue exactly how the attack lands so blue can build the detection that catches it. It’s not a separate team so much as a practice of closing the loop between offense and defense.
  • Cloud is the modern terrain all of this runs on — IAM, network segmentation, the metadata-endpoint problem from the Hook, secrets management. The attack surface moved into configuration, so a huge share of real incidents are now cloud-misconfiguration incidents.

And the application-security track you may already know — OWASP Top 10, OAuth, JWT — is the appsec rung of this same ladder: the foundations mindset applied specifically to the web application layer you build every day. OWASP’s Top 10 is literally a “what can go wrong” list for web apps, ranked by real-world data. When you studied IDOR and deny-by-default authorization, you were doing Shostack’s second question against HTTP endpoints. This cluster widens that lens to the whole system.

Where you stand

You are not starting from zero. As a middle-plus engineer you already reason about edge cases, failure modes, and untrusted input — security is that same rigor turned adversarial. The goal of this cluster isn’t to make you a full-time red-teamer or a SOC analyst; it’s to make you bilingual: able to think like an attacker well enough to anticipate the abuse, and like a defender well enough to build the control. That fluency is what lets you sit in a design review and say “wait — what stops someone from pointing that fetch at the metadata endpoint?” before the code ships, not three weeks after.

Pick the best fit

Your team finds that an internal reporting endpoint returns any user's data if you pass their id, but it's only reachable from inside the corporate VPN. Someone says 'low risk, it's internal.' How should a security-competent engineer frame this?

Quiz

A teammate says: 'Ransomware is a vulnerability we need to patch.' What's the precise correction?

Quiz

In Shostack's four questions, which one does a blue team (detection, monitoring, incident response) primarily live in?

Order the steps

Order Shostack's four security questions as you'd work them on a new feature, from first to last:

  1. 1 What are we building? (draw the system and its trust boundaries)
  2. 2 What can go wrong? (enumerate how each part can be abused)
  3. 3 What are we going to do about it? (choose mitigations, or accept/transfer)
  4. 4 Did we do a good job? (verify the controls actually hold)
Recall before you leave
  1. 01
    State Shostack's four security questions in order and explain why internalizing them — rather than memorizing tools — is the actual 'security foundation.'
  2. 02
    Define threat, vulnerability, and risk so they can't be confused, and explain why the distinction changes what you actually do.
  3. 03
    Map the cybersecurity cluster: how do foundations, red, blue, cloud, and the appsec track relate?
Recap

Security is a way of thinking, not a feature you bolt on: a security-competent engineer asks not just “does this work correctly?” but “what can an attacker make this do that I didn’t intend?” Adam Shostack’s four questions — what are we building, what can go wrong, what are we going to do about it, did we do a good job — are the frame that scales from one endpoint to a whole platform, and internalizing them is what “having a security foundation” really means. Keep three words crisp: a threat is an actor with a goal (you can’t delete it), a vulnerability is a flaw in your code (you can remove it), and risk is likelihood × impact of the two meeting (it’s what you triage on). Defense in depth assumes every layer eventually fails, so you stack independent controls. On the map, foundations is the mindset; red lives in “what can go wrong,” blue in “what do we do” and “did it work,” purple closes the loop between them, and cloud is the terrain — while the OWASP/OAuth/JWT appsec track is that same mindset applied to the web layer you already build. The aim is to be bilingual in attacker and defender thinking, so you catch the metadata-endpoint question in the design review, not in the incident channel.

Practice

Start at the top. Tasks go easiest → hardest: recall a fact, apply it to a case, then a senior-level stretch. Open one, attempt it, then reveal.

recallapplystretch0 of 5 done

Something unclear?

Ask a question about this lesson. Questions are anonymous and go straight to the author to make the lesson better.

shortcuts expand
search
K
prev piece
k
next piece
j
cycle tier
t
this menu
?
sources2
expand
  1. 01
  2. 02

Trademarks belong to their respective owners. Editorial reference only.