Threat Modeling Basics: Find Risks Before They Ship

Learn a practical threat modeling workflow: scope a system, map data flows and trust boundaries, prioritize risks, and choose defenses before release.

published: reading time: 15 min read author: Geek Workbench
Quick Summary

Threat modeling helps a team find ways a system could be misused by mapping assets, data flows, trust boundaries, attacker goals, and controls. This guide uses a private-notes app to show how a missing ownership check can expose another user's data, then uses STRIDE and risk prioritization to choose mitigations and verification evidence. Use the workflow to make design assumptions visible, assign follow-up work, and revisit the model as the system changes.

Threat Modeling Basics: Find Risks Before They Ship

Introduction

Suppose a note-sharing API confirms that a request has a valid session but never checks whether the requested note belongs to that account. One user can change an ID and read another user’s notes. Threat modeling helps teams find that path before release by tracing sensitive data, trust boundaries, attacker goals, and controls.

You do not need a dedicated security team or a week-long workshop to start. A developer, product owner, and someone familiar with operations can model one feature in an hour, record the assumptions, and agree on the risks that deserve action. This guide walks through that process with a small note-sharing app.

Scope the System and Its Assets

Start with one feature or data flow, not an entire company. State what the model covers, what it excludes, and the deployment assumptions you are making. For example: “This review covers creating and reading private notes through the web app and API. It excludes the identity provider’s internals and the cloud provider’s physical infrastructure.”

List the assets an attacker might want to read, alter, destroy, or use. Include more than database rows: account credentials, session tokens, encryption keys, administrative actions, service availability, and audit records can matter too. Note who owns each asset and what harm would follow if it were exposed or changed.

For each asset, ask:

  • Is it confidential, integrity-sensitive, or required for availability?
  • Which people or services should access it, and for what purpose?
  • Where is it created, processed, stored, backed up, and deleted?
  • Does it contain personal, regulated, or business-sensitive information?

Write down assumptions rather than letting them hide inside the diagram. “Only employees can reach the admin route” is an assumption to verify, not a control by itself.

Draw Data Flows and Trust Boundaries

Use a simple diagram first. Show users and external services as entities, code that processes requests as processes, durable storage as data stores, and arrows as named data flows. Label important data on the arrows, such as “session cookie,” “note text,” or “identity token.”

Then mark trust boundaries. A boundary is a change in control or privilege, not necessarily a firewall. The browser-to-service edge is one boundary; a service account accessing a database is another. Third-party identity, email, analytics, and storage services also sit across boundaries even when they are reliable vendors.

flowchart LR
    U[User browser] -->|HTTPS: note request and session cookie| W[Web application and API]
    W -->|Query using service identity| D[(Notes database)]
    W -->|OIDC authorization flow| I[Identity provider]
    W -->|Notification request| M[Email provider]

The diagram omits deployment details to keep the example readable. In a real review, annotate which side controls each component, how service identities authenticate, whether data is encrypted in transit, and where logs or backups create additional copies. A diagram should answer “what talks to what, with which data?” without pretending to be a full infrastructure inventory.

Identify Attacker Goals and Threats

Threats are easier to assess when phrased as outcomes an attacker wants. A person with a stolen session may try to read another user’s notes. A malicious user may try to change a note they do not own. A compromised API may be used to send spam or query the database beyond its intended role.

Consider different actors and starting positions: an unauthenticated internet user, a normal account holder, a user with a stolen device, a compromised third-party service, or an insider with excessive access. You do not need to assume a movie-style attacker. Misconfiguration, confused identities, and ordinary mistakes often create exploitable paths.

For every important flow, ask what can go wrong with who sent it, what it contains, where it goes, and what the receiver trusts. Check confidentiality, integrity, availability, authentication, authorization, and accountability where relevant. This can expose threats such as forged requests, tampered identifiers, replayed tokens, unsafe redirects, weak tenant isolation, or sensitive values in logs.

Use STRIDE as One Threat-Finding Method

STRIDE groups threat ideas into six categories. It is a prompt for a review, not a universal checklist and not proof that a system is secure.

Category Question to ask Example in the note app
Spoofing Can an attacker pretend to be another user or service? A stolen session cookie is accepted as the note owner.
Tampering Can data or a request be changed without authorization? A user edits the note ID in a request to target someone else’s note.
Repudiation Can an action be denied because evidence is missing or unreliable? The service cannot determine which account deleted a note.
Information disclosure Can data reach someone who should not see it? An API response includes another user’s private note.
Denial of service Can the attacker make a service unavailable or too costly? Large searches exhaust database connections.
Elevation of privilege Can an actor gain authority beyond their role? A normal account invokes an admin-only export endpoint.

Apply categories to components and flows that make sense. Repudiation may matter greatly for financial transfers and less for a temporary draft. Do not force every category onto every arrow. Other methods, such as abuse cases, attack trees, or privacy threat analysis, can reveal issues that a STRIDE pass misses.

Worked Example: Private Notes

Suppose a small app lets signed-in users create, edit, and delete private notes. Notes are stored in a shared database. The service obtains user identity from an OIDC login and sends an optional email when a note is shared.

Scope and assets

The model covers browser requests, API authorization, note storage, and the email notification integration. It treats the identity provider and email provider as external systems. The main assets are note contents, account sessions, user-to-note ownership, and service credentials. The expected behavior is that a signed-in user can access only notes they own or that have been explicitly shared with them.

A likely attack path

The API receives GET /notes/4821, authenticates the session, then loads note 4821. A developer might check that the request has a valid user but forget to compare the note’s owner with that user. An attacker changes the identifier from their own note to another one. Authentication succeeds, yet authorization fails to protect the data.

The threat is information disclosure through a broken object-level authorization check. A related tampering threat appears if the same missing ownership check protects updates or deletes. A STRIDE label helps name the issue, but the important statement is the concrete path and impact.

Mitigations and evidence

  • Enforce ownership or explicit sharing in the server-side query or authorization layer for every read, update, delete, and export operation.
  • Deny access by default. A valid session proves identity, not permission to every object.
  • Add tests that use two separate accounts and attempt cross-account reads and writes.
  • Log denied access with a request identifier and actor ID, while excluding note bodies and session secrets.
  • Rate-limit expensive listing and search operations, then monitor denials and unusual request volume.

These controls address different parts of the path. The authorization check blocks the access, the test guards against regression, and the log helps an operator investigate. Rate limiting reduces an availability risk but does not fix authorization. Teams can deepen the review with an existing guide to authentication and authorization and a post on common web threats.

Prioritize Risks and Choose Mitigations

Record each risk in a sentence with the attacker, action, vulnerable condition, and impact. For example: “A signed-in user can change a note ID to read another user’s note because the API checks login but not ownership.” This is more actionable than “broken access control.”

Estimate likelihood and impact using a scale the team can explain. Consider how reachable the flow is, how hard the attack is, how much privilege it needs, how many users or records are affected, and whether detection is likely. A simple low/medium/high rating is adequate if people use it consistently. Avoid false precision such as a risk score with several decimal places when the evidence is uncertain.

Prioritize severe impacts, easy-to-reach paths, reusable exploit opportunities, and risks that expose many users or tenants. Then choose a response:

  • Mitigate: change design or add a control, then record how you will verify it.
  • Avoid: remove the risky behavior or feature from scope.
  • Transfer: use a contract or provider for part of the impact while keeping your own responsibilities clear.
  • Accept: document who accepts the residual risk, why, and when it will be reviewed.

Controls should match the path. Prevent unauthorized access with server-side authorization, reduce credential exposure with scoped secrets, limit damage with least privilege, and improve detection with useful audit events. For secrets storage practices, see secrets management. For network exposure, see network security.

When to Use

Threat modeling is especially useful when a change introduces a new data type, external integration, identity flow, privilege level, public endpoint, or tenant boundary. It also helps before a major release, during architecture review, after an incident, or when teams need to explain why a security control exists.

Keep the session proportional. A small feature may need a short diagram and a few risks. A service holding sensitive data or crossing several organizational boundaries deserves deeper review, technical validation, and security expertise. Revisit the model when its assumptions stop matching production.

Production Failure Scenarios

  • The diagram drifts: A team adds a background worker or new data store, but the threat model still describes the old flow. Reviews miss a path that now holds copies of sensitive data. Assign an owner and update the model when architecture changes.
  • Authentication is mistaken for authorization: A request carries a valid token, so the service assumes the requested object is allowed. Test access across users and tenants at each object operation.
  • Logs become a second data leak: Debug logging captures note bodies, bearer tokens, or reset links. Define safe fields and review logs as data stores with their own access and retention controls.
  • A vendor integration is over-trusted: The app accepts a callback or notification without validating its signature, audience, or replay window. Treat inbound vendor data as untrusted input and verify the documented security properties.
  • A control exists only in a diagram: The team records “rate limited” or “encrypted” without confirming configuration, coverage, and ownership. Link each mitigation to an implementation or a verification step.

Trade-Off Table

Choice Benefit Cost or risk Good fit
Lightweight whiteboard model Fast, encourages broad participation Can miss implementation details Early design or a small feature
Detailed data-flow inventory Exposes stores, identities, and system boundaries Takes longer to maintain Sensitive data or many integrations
STRIDE pass Gives a repeatable set of threat prompts Can become mechanical if used without context Reviewing components and flows
Attack tree or abuse case Follows an attacker goal through concrete steps Needs clear goals and system knowledge Investigating a high-impact attack path
Accept residual risk Avoids disproportionate work when impact is bounded Leaves exposure in place and needs accountable approval Documented, time-bound low or understood risk

Pick the smallest method that answers the current design question. A short, maintained model is more useful than a large document that no one checks after it is written.

Observability Checklist

  • Record security-relevant events such as denied access, privilege changes, recovery actions, and sensitive exports.
  • Include actor, target, action, outcome, timestamp, and a request or trace identifier when appropriate.
  • Exclude passwords, session cookies, bearer tokens, secret keys, and private note contents from logs.
  • Alert on patterns that matter, such as repeated cross-account denials or sudden export volume; tune alerts to avoid noise.
  • Restrict log access and retention because logs may reveal identities, object IDs, and operational details.
  • Test that event fields are present and that monitoring works during incident exercises.

Observability does not prevent an attack by itself. It helps the team notice and investigate suspicious behavior, and it can reveal when assumptions in the threat model no longer hold.

Security and Compliance Notes

Threat modeling can support security reviews and help teams map design risks to internal policies or external requirements. It does not establish compliance on its own. A model needs evidence: implemented controls, review records, test results, access policies, and operational practices appropriate to the system and jurisdiction.

Minimize the data collected and retained. Record why sensitive data exists, which components process it, who can access it, and when it should be deleted. If personal or regulated data is involved, consult the organization’s privacy, legal, and security owners about applicable requirements. Do not put secrets or real personal data into a threat-model diagram or an issue tracker.

Common Pitfalls / Anti-Patterns

  • Modeling everything at once: The scope grows until the review becomes too vague to finish. Start with one feature and expand only when a dependency changes the risk.
  • Treating STRIDE as a compliance checklist: A completed table can still miss the real attack path. Tie each finding to an actor, entry point, condition, and impact.
  • Listing controls without testing them: “Use encryption” says little about key access, coverage, or failure behavior. Name the control owner and the evidence that would show it works.
  • Ignoring abuse by legitimate users: Authentication does not make every action safe. Consider compromised accounts, malicious customers, and over-privileged support tools.
  • Scoring without rationale: A number without assumptions creates arguments instead of decisions. Write down the facts and uncertainty behind the rating.
  • Letting the document go stale: An old model can mislead reviewers. Update it when a new component, integration, identity, or data store changes the flow.

Quick Recap Checklist

  • Scope one feature or flow and write down assumptions.
  • Identify sensitive assets and their security needs.
  • Draw components, data stores, external entities, and named flows.
  • Mark boundaries where control, identity, or privilege changes.
  • Describe plausible attacker goals and concrete attack paths.
  • Use STRIDE or another method as a prompt, not as a substitute for judgment.
  • Prioritize by reachability, likelihood, impact, and affected users.
  • Assign mitigations, owners, verification evidence, and accepted residual risk.
  • Revisit the model when the production design changes.

Interview Questions

1. What is a trust boundary in a threat model?

A trust boundary marks a change in who controls a component or what identity and privilege the system assumes. A browser request entering an API crosses a boundary even when both systems use the same cloud network, because the browser is outside the service's control.

2. Does STRIDE need to be applied to every component and data flow?

No. STRIDE is a set of prompts that helps a team find threat ideas. Apply categories where they fit, and use other approaches such as abuse cases or attack trees when they better match the question. A completed STRIDE pass does not prove that all threats are known.

3. How do authentication and authorization differ in the worked example?

Authentication establishes which account made a request. Authorization decides whether that account may read or change a particular note. A valid session is not permission to access every note in the database.

4. How should a team handle a risk it will not fix before release?

Record the risk, its impact and likelihood assumptions, the reason for deferral, the person accepting it, and a review date or trigger. The team should also document any temporary controls and the conditions that would make the risk unacceptable.

Further Reading

Conclusion

Threat modeling works best as a focused design conversation backed by a diagram and concrete decisions. Scope one flow, follow the data across trust boundaries, describe what an attacker could achieve, and rank the risks by likely harm. Use STRIDE if it helps your review, then assign controls and evidence that fit the actual paths. Keep the model current as the system changes; that is what turns it from paperwork into a useful engineering tool.

Category

Related Posts

Assets, Trust Boundaries, and Attack Surface

Learn how to inventory digital assets, trace data flows, mark trust boundaries, and identify exposed entry points with a practical example.

#cybersecurity #threat-modeling #attack-surface

Security Principles and Defense in Depth: Practical Guide

Learn how least privilege, secure defaults, separation of duties, and defense in depth reduce security risk without adding controls that create extra friction.

#cybersecurity #security-principles #defense-in-depth

Threats, Vulnerabilities, and Risk: A Security Primer

Learn how assets, threats, vulnerabilities, likelihood, impact, and controls fit together through a practical risk assessment for a small donation website.

#cybersecurity #security-fundamentals #risk-management