A team draws a data flow diagram for a sports club's new membership page. Members' card details go from the page to an outside payment company, which the club does not control.
Finding threats in a design before it is built
An architect's drawing shows where a burglar could get in before a single brick is laid, and moving a window on paper costs nothing. Threat modelling does the same for a computer system: it examines a drawing of the system for ways it could be misused. No background is assumed. A security professional leads this work because a weakness found in a design is far cheaper to remove than one found in use.
By the end of this unit you will be able to:
- Explain what threat modelling is and state its four questions
- Tell apart the proactive and reactive approaches
- Choose between asset-focused, attacker-focused and software-focused starting points
- Name the five elements of a data flow diagram and explain why trust boundaries matter
- Explain what reduction analysis identifies
A booking page, drawn on one sheet of paper
An illustrative example
A community library plans a web page where residents can book its meeting room and pay a deposit by card. A volunteer has offered to build it over a weekend. The librarian draws the idea on one sheet: a resident, the booking page, a list of bookings and a payment company.
A trustee studies the sheet and asks three things. Could someone book the room in another person's name? Could someone see who else has booked? Could someone cancel every booking at once? Nothing has been built, and three problems have been found.
Why could the trustee find problems in a system that does not exist yet, and why was a single sheet of paper enough?
Thinking like the intruder, on paper
Threat modelling is a structured way of examining a picture of a system to find what could go wrong with its security and , and deciding what to do about each finding. The picture can be a sketch. What makes the work structured is that every part of the picture is questioned in turn.
Four questions frame the work. They are known as the four-question framework of Adam Shostack, who led at Microsoft. The Threat Modeling Manifesto, a statement of shared principles written by practitioners, adopts them.
- What are we working on?
- What can go wrong?
- What are we going to do about it?
- Did we do a good enough job?
The library's sheet of paper answers the first question. The trustee's three worries answer the second. The third and fourth are still to come, and they can be answered before the volunteer writes anything.
The people in the room matter. A designer knows how the system works, a security specialist knows how systems are attacked, and the owner in the business knows what a failure would cost.
Before release, and after it
The proactive approach, also called the defensive approach, models threats while the system is being designed and built. It is the preferred one, because a change to a drawing costs minutes and a change to a working system costs weeks.
Not every threat can be foreseen. The reactive approach, also called the adversarial approach, looks for weaknesses after the system is in use.
- Penetration test
- An authorised attempt by a specialist to break into the working system.
- Threat hunting
- A search of the organisation's own systems for signs of an intruder that no alarm has reported.
- Fuzz testing
- Feeding a program large amounts of unexpected or malformed input to see whether it fails in an unsafe way.
A weakness found reactively is repaired with an update to a system that people already rely on. The repair is slower, costs more and can itself cause faults.
A threat model is not drawn once and filed. It is revisited whenever the system changes: a new feature, a new supplier, a new kind of user.
Three places to start: assets, attackers, software
A team needs a way in. Three are in common use.
- Focused on assets
- Start from what is valuable, such as the list of bookings, and ask what threatens each item.
- Focused on attackers
- Start from who might attack and what they want, and ask how they would go about it.
- Focused on software
- Start from the design of the system and ask what could go wrong at each part and each connection.
Teams that build software mostly use the third, because they already have the design in front of them.
An attacker-focused model needs a view of who the threat actors are. An insider is an employee or contractor who already has legitimate access. Criminals want money. A state wants secrets or the power to disrupt, and has time and resources. A hacktivist attacks to promote a cause. A competitor wants commercial advantage.
Drawing the system: the data flow diagram
The usual picture is a data flow diagram: a drawing of where data comes from, where it goes and where it is kept. It has five kinds of element.
- External entity
- A person or another system outside the system's control that sends or receives data. Drawn as a rectangle. The resident and the payment company are external entities.
- Process
- A part of the system that does something with data. Drawn as a circle. The booking page is a process.
- Data store
- A place where data is kept. Drawn as two parallel lines. The list of bookings is a data store.
- Data flow
- A movement of data from one element to another. Drawn as an arrow.
- Trust boundary
- A line across which the level of trust changes. Drawn as a dotted line. One runs between the resident's own computer and the library's booking page.
Where threats enter a simple booking system
Read this figure as text
A data flow diagram shows where data comes from, where it goes and where it is kept. The library's booking page is drawn with its trust boundary, and the flows that cross that boundary are marked as the places where threats concentrate.
- The resident is an external entity, outside the library's control. A data flow diagram draws an external entity as a rectangle.
- The resident's booking request crosses the trust boundary, the dotted line between the resident's own computer and the library's booking page. Whatever arrives this way may be false or hostile and must be checked.
- The booking page is a process, drawn in a data flow diagram as a circle. It reads and writes the list of bookings, a data store drawn as two parallel lines, inside the boundary.
- A deposit request crosses the boundary from the booking page to the payment company, another external entity.
- The payment result crosses the boundary back from the payment company to the booking page, and it too is checked before the page acts on it.
Threats gather where a data flow crosses a trust boundary. Whatever arrives from the less trusted side may be false or hostile, so it must be checked before the system acts on it. All three of the trustee's questions concern the flow from the resident to the booking page.
Breaking the system down: reduction analysis
A whole system is too large to question at once. Reduction analysis, also called decomposition, breaks it into smaller parts so that each can be examined. For each part, five things are identified.
- Trust boundaries
- Every place where the level of trust changes.
- Data flow paths
- The routes data takes between the parts.
- Input points
- Every place where the part receives something from outside, also called entry points. A form that a resident fills in is one.
- Privileged operations
- Any action that needs more than an ordinary user's rights, such as cancelling another person's booking.
- Security stance and approach
- The security rules and assumptions already in place: how users prove who they are, what is recorded, what is forbidden.
In the library's design, the booking form is an input point on a , and cancelling bookings is a privileged operation. If the page connects to the list of bookings with full rights over it, anyone who misleads the page gains those rights too.
What a threat model produces, and what it is not
The result is the diagram and a list of threats. Each threat carries a rating and a decision: change the design so the threat cannot arise, add a control, , or have the owner accept it. The decisions are recorded and later checked, which answers the fourth question.
| Activity | Looks at | When | Finds |
|---|---|---|---|
| Threat model | A design, on paper | While designing and building, and on each change | What could go wrong |
| Vulnerability scan | A working system | Repeatedly, by software | Known weaknesses |
| Penetration test | A working system | After building | What can really be broken into |
| Risk assessment | An organisation or a system | At agreed intervals | sized by likelihood and impact, for management |
A system whose threats were dealt with in its design is called secure by design. One whose settings are safe as delivered, with nothing left for the buyer to switch on, is called secure by default.
Common misconception
“A penetration test before release makes a threat model unnecessary.”
A test finds some of the faults that were built. A model stops faults from being built. A flaw in the design itself, such as trusting whatever a user's computer sends, may pass a test and cannot be fixed cheaply afterwards.
A question, worked through
A team is threat modelling a new online shop. Its diagram shows customers' own computers, the shop's web application, an orders database and a payment company. A dotted line separates the customers' computers from the web application. The team has two hours and cannot examine every element.
Where should the team look FIRST?
Decide on your answer, then open the reasoning
- The question asks where to begin when time is short, so it is asking where threats are most concentrated.
- All four options are real parts of the diagram, and each could hold a threat.
- Rule out c and d: a process and a data store that sit wholly inside the shop's own system receive only what the shop's other parts pass to them.
- Between a and b: both are data flows. The flow in b runs between two parts the shop controls. The flow in a crosses a trust boundary from computers the shop does not control.
- Choose a. Whatever crosses the boundary may be false or hostile, so that is where the most threats enter.
Answer: A. The flows that cross the dotted line into the web application
Choosing between good answers
- A question asks when threat modelling should be done
- choose during design, before the system is built, and again whenever it changes.
- The activity described happens after deployment, such as penetration testing, threat hunting or fuzz testing
- it belongs to the reactive, or adversarial, approach.
- A question asks where to concentrate in a data flow diagram
- choose the points where data crosses a trust boundary.
- A team starts from what is valuable, from who might attack, or from the design
- the approaches are asset-focused, attacker-focused and software-focused, in that order.
- Two answers both find weaknesses and one works on a design while the other needs a running system
- the first is threat modelling and the second is testing.
Try it
Walk the diagram of a web shop and see which threat appears at each element and each boundary.
Loading the preview.
Check your understanding
5 questions on this unit, easiest first. Confirm an answer to see the reasoning for it, then the right answer, the other options and the rule to reuse. Your answers are kept in this browser and feed readiness and review.
These questions are drafts that no named reviewer has approved yet.
Question 1 of 5
What to remember
- Threat modelling examines a picture of a system to find what could go wrong and decide what to do about it.
- Its four questions: what are we working on, what can go wrong, what are we going to do about it, did we do a good enough job.
- The proactive approach works at design time. The reactive approach works after deployment, through testing and hunting.
- A data flow diagram has external entities, processes, data stores, data flows and trust boundaries. Threats gather at the boundaries.
- Reduction analysis identifies trust boundaries, data flow paths, input points, privileged operations and the security stance.
- A threat model is not a penetration test and not an organisation's risk assessment.
Say it from memory
What is threat modelling, what are its four questions, and what does reduction analysis identify?
A structured examination of a picture of a system, best done at design time, to find what could go wrong and decide what to do. The questions: what are we working on, what can go wrong, what are we going to do about it, did we do a good enough job. Reduction analysis identifies trust boundaries, data flow paths, input points, privileged operations and the security stance. Named methods include STRIDE, DREAD and PASTA.
How does the proactive approach to threat modelling differ from the reactive approach, and which is preferred?
The proactive, or defensive, approach models threats while the system is designed and built. The reactive, or adversarial, approach looks for weaknesses once the system is in use, through penetration tests, threat hunting and fuzz testing. Proactive is preferred, because a change to a drawing costs far less than a change to a working system.
Name the three places a threat model can start, and which one software teams mostly use.
Focused on assets: start from what is valuable. Focused on attackers: start from who might attack and what they want. Focused on software: start from the design and ask what could go wrong at each part and connection. Software teams mostly use the third.
Name the five elements of a data flow diagram, and say where threats gather.
External entities, processes, data stores, data flows and trust boundaries. Threats gather where a data flow crosses a trust boundary, because whatever arrives from the less trusted side may be false or hostile.
What is the difference between secure by design and secure by default?
A system is secure by design when its threats were dealt with in its design. It is secure by default when its settings are safe as delivered, with nothing left for the buyer to switch on.
Sources
- Threat Modeling Manifesto, Threat Modeling Manifesto working groupThreat modelling as analysing representations of a system to highlight concerns about security and privacy, and the four key questions.
- Threat Modeling (resources page), Shostack + AssociatesThe four questions as Adam Shostack's four-question framework, followed by most modern threat modelling approaches.
- Uncover Security Design Flaws Using The STRIDE Approach (MSDN Magazine, November 2006), MicrosoftThe data flow diagram symbols: interactor as a rectangle, process as a circle, data store as two parallel lines, data flow as an arrow and trust boundary as a dotted line.
- Improving Web Application Security: Threats and Countermeasures, Chapter 3: Threat Modeling, Microsoft patterns & practicesDecomposing an application to identify trust boundaries, data flow, entry points and privileged code and to document its security profile, and threat modelling repeated through the life of an application.
- NIST SP 800-115: Technical Guide to Information Security Testing and Assessment, NISTPenetration testing as authorised testing of a working system.
- Secure by Design, CISASecure by design and secure by default as properties of how a product is built and delivered.
- OWASP Threat Modeling Project, OWASP FoundationThreat modelling as a family of techniques and methods, of which no single one is definitive.