Fifty threats, one week
STRIDE gave the canteen team 52 questions. Answering them left a dozen real threats. The team has one week before the app goes live.
They cannot fix everything, so they need an order and a decision for each threat. A ranking that anyone can check beats the loudest voice in the room.
By the end of this lesson
Note
I can rank threats by risk and choose a response for each one.
Key words
| Word | What it means | Example |
|---|---|---|
| Likelihood | how probable it is that a threat happens | 1 to 5 |
| Impact | how much harm it does if it happens | 1 to 5 |
| Risk score | likelihood times impact | |
| Mitigate | add a control that makes a threat less likely or less harmful | |
| Residual risk | the risk left after a control is in place |
The cells students fill in are left blank in this preview.
Starter
Have a go
Starter
4 questionsLikelihood times impact gives a score
Give each threat a likelihood and an impact from 1 to 5. Their product is the risk score, from 1 to 25. The canteen team agreed three bands. A score of 10 or more is fixed now, 5 to 9 gets a planned fix, and 1 to 4 is accepted and watched.
An older scheme, DREAD, scored five things. Teams gave the same threat very different scores, so it fell out of use.
Scoring three canteen threats
| Threat | Likelihood | Impact | Score | Band |
|---|---|---|---|---|
| Change the order number to see other orders | 4 | 3 | 12 | Fix now |
| Guess a weak password | 3 | 3 | 9 | Plan a fix |
| Edit the menu and deny it | 2 | 2 | 4 | Accept and watch |
The cells students fill in are left blank in this preview.
Check
Have a go
Check
3 questionsTry it: score and band three threats
threats = [["Guess a weak password", 3, 3], ["Flood the order page", 2, 3], ["Steal a backup", 1, 5]]
for t in threats:
score = t[1] * t[2]
if score >= 10:
decision = "fix now"
elif score >= 5:
decision = "plan a fix"
else:
decision = "accept and watch"
print(score, t[0], "->", decision)
# Multi-factor sign-in lowers the likelihood of a guessed password to 2. Try it.
Make a free account to save your work and track your progress.
Four ways to respond to a threat
You can mitigate a threat with a control. You can accept it and watch for it. You can transfer it, as the canteen does by letting the card company handle card numbers. You can avoid it by not building the feature.
A control lowers the likelihood or the impact. What is left is the residual risk, and someone with authority signs it off.
A common mistake
Warning
Many people think a threat is gone once it has a control. A control lowers the score, it rarely makes it zero. After the ownership check the order number threat still scores 3. Record the residual risk, so it is accepted on purpose.
Check
Have a go
Check
3 questionsWrite the ranking script, part 1
docker exec jupyter sh -c "mkdir -p steps && printf '%s\n' 'import sys' 'threats = [' ' [\"Change the order number to see other orders\", 4, 3],' ' [\"Guess a weak password\", 3, 3],' ' [\"Flood the order page\", 2, 3],' ' [\"Edit the menu and deny it\", 2, 2],' ' [\"Read card details on the way\", 1, 5],' ' [\"Steal a database backup\", 1, 5],' ' [\"Change orders on the kitchen screen\", 1, 4],' ']' 'controls = {' ' \"Change the order number to see other orders\": 1,' ' \"Guess a weak password\": 2,' '}' 'if \"after\" in sys.argv:' ' for t in threats:' ' if t[0] in controls:' ' t[1] = controls[t[0]]' 'rows = []' 'for t in threats:' ' rows.append([t[1] * t[2], t[1], t[2], t[0]])' 'rows.sort(key=lambda r: -r[0])' 'total = 0' 'for r in rows:' ' if r[0] >= 10:' ' decision = \"fix now\"' ' elif r[0] >= 5:' ' decision = \"plan a fix\"' ' else:' ' decision = \"accept and watch\"' > steps/rank.py"Shown here, not run. Press Start lab to type it into your own lab’s terminal.
Write the ranking script, part 2
docker exec jupyter sh -c "printf '%s\n' ' total = total + r[0]' ' print(str(r[0]).rjust(2), \"=\", r[1], \"x\", r[2], \" \", r[3].ljust(44), decision)' 'print(\"total risk\", total)' >> steps/rank.py"Shown here, not run. Press Start lab to type it into your own lab’s terminal.
Rank the seven threats
docker exec jupyter python3 steps/rank.pyShown here, not run. Press Start lab to type it into your own lab’s terminal.
Rank them again after two controls
docker exec jupyter python3 steps/rank.py afterShown here, not run. Press Start lab to type it into your own lab’s terminal.
What rank.py printed
| Run | Top threat | Fix now | Total risk |
|---|---|---|---|
| Before | Change the order number, 12 | 1 threat | 45 |
| After the ownership check and multi-factor | Guess a weak password and Flood the order page, 6 each | None | 33 |
The cells students fill in are left blank in this preview.
Check
Have a go
Check
3 questionsAssignment: rank the threats
Write the ranking the lab script made, without sorted.
score(likelihood, impact) returns their product. priority(points) returns 1 for 10 or more, 2 for 5 to 9 and 3 below that. rank(threats) takes a list of [name, likelihood, impact] and returns the names, highest score first. Threats with the same score keep their order, and the list you were given is not changed.
def score(likelihood, impact):
# Both are 1 to 5. The score is their product.
return 0
def priority(points):
# 1 for a score of 10 or more, 2 for 5 to 9, 3 for anything lower.
return 0
def rank(threats):
# threats is a list of [name, likelihood, impact]. Return the names, highest score first.
# Two threats with the same score keep their order in the list. Do not use sorted.
return []
Make a free account to save your work and track your progress.
Exit quiz
Have a go