SECURITY ENGINEERING · PART 8 · WRITING SECURE CODE · DESIGN · 109 OF 229

Threat Modeling With STRIDE, Step by Step

Threat modeling means taking a design and asking what can go wrong, before it is built. This episode walks through the four questions, how to draw a data flow diagram with trust boundaries, the six STRIDE categories with a concrete example and mitigation for each, and how to make threat modeling a lightweight habit rather than a heavy document.

  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

  • Four questions
  • data flow diagram with trust boundaries
  • STRIDE at each boundary
  • mitigate and track
  • keep it light

Notes

Four questions

Adam Shostack reduced threat modeling to four questions, and they are all you really need to remember. What are we building? Draw it. What can go wrong? Apply STRIDE to the drawing. What are we going to do about it? Choose mitigations. And did we do a good job? Review. Everything else, the diagrams, the categories, the tools, is detail in service of those four questions. A team that asks them honestly for an hour has done real threat modeling.

Threat modeling asks
  • 1. What are we building? (draw the system)
  • 2. What can go wrong? (STRIDE against the diagram)
  • 3. What are we going to do about it? (mitigations)
  • 4. Did we do a good job? (review it)
  • everything else is detail

Draw it

To answer what can go wrong, you first draw what you are building, as a data flow diagram. It has four kinds of element: external entities like users, processes like your services, data stores like databases, and the data flows between them. The crucial addition is trust boundaries: lines where data crosses from less trusted to more trusted, such as the internet reaching your server, or your app reaching the database. Threats cluster on those boundaries, so that is where you look hardest.

A data flow diagram
  • elements: external entities, processes, data stores, data flows
  • trust boundaries: lines where data crosses from less to more trusted (internet to server, app to database)
  • threats concentrate on the boundaries
  • keep it to one page, at the right level of detail

S: Spoofing

STRIDE is six categories, each the opposite of a security property. S is spoofing: pretending to be someone or something you are not, which attacks authentication. An attacker uses a stolen session or a forged token to act as another user, or a fake service impersonates a real one. The mitigations are the authentication tools from later episodes: strong login, multi-factor, mutual TLS between services, and tokens that are signed and properly verified. Every arrow crossing into trust is a spoofing question.

Spoofing -> Authentication
  • threat: an attacker claims to be another user, or a fake service claims to be yours
  • examples: stolen session, forged token, phishing, a spoofed API caller
  • mitigate: strong authn, MFA, mutual TLS between services, signed and verified tokens

T: Tampering

T is tampering: changing data or code without permission, which attacks integrity. An attacker edits a price in a request the client controls, modifies a token, alters a stored file, or poisons a dependency in the build. The mitigations are TLS for data in transit, input validation and server-side authorization on every write so the client cannot be trusted, integrity checks and HMACs, and signed build artifacts. Never trust that data arrived unchanged just because you sent it a certain way.

Tampering -> Integrity
  • threat: data changed in transit, in storage, or in a request the user controls
  • examples: edit a price in a request, modify a JWT, alter a file, poison a dependency
  • mitigate: TLS, input validation, integrity checks, signed artifacts, authz on every write

R: Repudiation

R is repudiation: being able to deny you did something because nothing reliably recorded it, which attacks accountability. There is no audit log, the logs can be edited, or everyone shares one admin account so you cannot tell who acted. The mitigations are tamper-evident audit logs, individual identities rather than shared accounts, synchronised time, and signed log entries. It is easy to forget, because it is not about stopping an action but about proving who took it.

Repudiation -> Non-repudiation
  • threat: a user or attacker performs an action and there is no reliable record
  • examples: no audit log, logs that can be edited, shared accounts so you cannot tell who acted
  • mitigate: tamper-evident audit logs, per-user identity, time sync, signed log entries

I: Disclosure

I is information disclosure: exposing data to someone who should not see it, which attacks confidentiality. Verbose error messages leak internals, one user reads another's records through a changed identifier, secrets end up in logs, a storage bucket is left open, or an API returns far more fields than the screen needs. The mitigations are access control, encryption, returning the minimum data, and careful handling of errors and logs. This is one of the most common categories you will find in real reviews.

Disclosure -> Confidentiality
  • threat: data exposed to an unauthorised party
  • examples: verbose errors, one user reading another's records, secrets in logs, an open bucket, too much in an API response
  • mitigate: access control, encryption, minimal responses, careful errors and logging

D: Denial of service

D is denial of service: making the system unavailable or too slow, which attacks availability. A flood of requests, a single very expensive query, a huge upload, or an algorithm that becomes slow on crafted input, like the regular-expression denial of service we measured in Part three. The mitigations are rate limiting, quotas, timeouts, input size limits, autoscaling, and upstream protection such as a content delivery network. Availability is a security property too, not only an operations concern.

DoS -> Availability
  • threat: the system is made unavailable or too slow
  • examples: flood of requests, one expensive query, a huge upload, an algorithm that is slow on bad input (ReDoS)
  • mitigate: rate limiting, quotas, timeouts, input size limits, autoscaling, a CDN or DoS protection

E: Elevation

E is elevation of privilege: gaining rights you were never meant to have, which attacks authorization. A normal user reaches an administrator function because the check was only in the user interface, an injection flaw runs code on the server, or a container escapes to the host. The mitigations are least privilege everywhere, server-side authorization checks on every action rather than hiding buttons, patching, and strong isolation. This is often the final step that turns a small foothold into a full compromise.

Elevation -> Authorization
  • threat: a user gains higher privileges than intended
  • examples: a normal user reaching admin functions, a container breakout, an injection that runs code, a missing server-side authz check
  • mitigate: least privilege, server-side authz on every action, patching, isolation

Make it a habit

The failure mode of threat modeling is turning it into a heavy document nobody repeats. Keep it light. Model new features and significant changes, not every small ticket. One page, one hour, with the people who actually know the system in the room. Use a tool if it helps, such as OWASP Threat Dragon, or just a whiteboard. The output is a short list of threats and the mitigations you chose, tracked like any other work, and revisited when the design changes. Light and regular beats thorough and never.

Keep it practical
  • model new features and major changes, not every ticket
  • one page, one hour, the people who know the system
  • tools: OWASP Threat Dragon, pytm, or just a whiteboard
  • output: a short list of threats and chosen mitigations, tracked
  • revisit when the design changes

Common mistakes

Mistakes. A diagram with no trust boundaries, which hides exactly where threats live. Skipping the less obvious categories, especially repudiation and denial of service. The security team modeling alone without the people who built the system, who know where the real weak points are. Finding threats and never tracking or fixing them. Modeling once at the start and never again. And chasing completeness so hard that the exercise never finishes and so never ships value.

Avoid these
  • a diagram with no trust boundaries
  • skipping repudiation and DoS
  • security team models alone, without the builders
  • threats found but never tracked or fixed
  • modeling once, never again
  • aiming for completeness and so never finishing

Say it like this

In the interview: I use the four questions, what are we building, what can go wrong, what are we going to do, and did we do a good job. I draw a data flow diagram with trust boundaries, then apply STRIDE, spoofing, tampering, repudiation, information disclosure, denial of service and elevation of privilege, at each boundary. For each real threat I pick a mitigation and track it like any other work. I keep sessions to about an hour with the engineers who know the system, and I revisit when the design changes.

In the interview
  • "Four questions: what are we
  • building, what can go wrong, what do we do, did we do
  • well. I draw a data flow
  • diagram with trust
  • boundaries, apply STRIDE at each boundary, pick
  • mitigations per threat, and track them. I keep it to an hour and repeat on changes."

Interview questions

Q1What is threat modeling?

A structured process of examining a system design to identify what could go wrong, before it is built or deployed. It answers four questions: what are we building, what can go wrong, what will we do about it, and did we do a good job.

Q2What does STRIDE stand for?

Spoofing, Tampering, Repudiation, Information disclosure, Denial of service and Elevation of privilege. Each category is the violation of a security property: authentication, integrity, non-repudiation, confidentiality, availability and authorization respectively.

Q3What is a data flow diagram in threat modeling?

A one-page diagram showing external entities, processes, data stores and the data flows between them, with trust boundaries marking where data crosses from less trusted to more trusted zones. Threats concentrate at those boundaries.

Q4What is a trust boundary?

A line in a system where data or control passes between components with different levels of trust, such as from the internet to a server or from an application to a database. Trust boundaries are where most threats arise and where controls are most needed.

Q5Give an example of each STRIDE category.

Spoofing: using a stolen token to impersonate a user. Tampering: editing a price in a request. Repudiation: acting with no audit log. Information disclosure: reading another user's records. Denial of service: flooding an endpoint. Elevation of privilege: a normal user reaching admin functions.

Q6When should you threat model?

During design of new features and significant changes, and again when the design changes materially. It is most valuable early, when fixing issues means changing a diagram rather than production code, and should be a repeated, lightweight habit.

Q7What tools support threat modeling?

OWASP Threat Dragon and the Microsoft Threat Modeling Tool for drawing and analysing diagrams, pytm for defining a model as code, and attack-tree tools. Many effective sessions use only a whiteboard; the method matters more than the tool.

Q8How do you keep threat modeling lightweight?

Limit scope to new or changed features, timebox to about an hour, involve the engineers who know the system, produce a short tracked list of threats and mitigations rather than a large document, and repeat as the design evolves instead of aiming for one-time completeness.