Easier to read with cream paper, a tint, more contrast or larger text? Choose your colours and text, once, for every page.

Free lesson

Finding threats with STRIDE

After this lesson: I can use STRIDE to list the threats to each part of a data flow diagram.

60 min lesson4 commandsJupyterLab data science lab: pandas, Matplotlib and scikit-learn in the browser

A quick check that you are not a bot, then your own lab opens on the interactive lesson.

Already have an account? Sign in

A blank page finds nothing

Ask a group "what could go wrong with the canteen app?" and you get three ideas, all about passwords. Then the room goes quiet.

A checklist works better than a blank page. STRIDE is a checklist of six kinds of threat that you walk across every part of your diagram.

By the end of this lesson

Note

I can use STRIDE to list the threats to each part of a data flow diagram.

Key words

WordWhat it means
Threatsomething that could go wrong for the system
STRIDEsix kinds of threat, one letter each
Spoofingpretending to be someone or something else
Tamperingchanging data or code without permission
Repudiationdenying you did something, with no proof either way
Elevation of privilegegaining rights you were not given

The cells students fill in are left blank in this preview.

Starter

Have a go

Starter

4 questions
Have a go: your answers are marked here and then forgotten. Sign in if you would like your score kept, and to pick up where you left off.Sign in to keep your score

Each letter breaks one property

STRIDE was written at Microsoft in 1999. Each letter is the opposite of something you want. Spoofing breaks authentication. Tampering breaks integrity. Repudiation breaks the proof of who did what.

Information disclosure breaks confidentiality. Denial of service breaks availability. Elevation of privilege breaks authorisation. Knowing the property tells you the kind of fix.

STRIDE in the canteen app

LetterThreatProperty brokenExample
SSpoofingAuthenticationSigning in as another student
TTamperingIntegrityChanging the price in an order
RRepudiationProof of actionAn admin denies changing the menu
IInformation disclosureConfidentialityReading other orders
DDenial of serviceAvailabilityFlooding the order page at 11:55
EElevation of privilegeAuthorisationA student reaching the Admin page

The cells students fill in are left blank in this preview.

Check

Have a go

Check

3 questions
Have a go: your answers are marked here and then forgotten. Sign in if you would like your score kept, and to pick up where you left off.Sign in to keep your score

Not every letter fits every part

A data flow cannot sign in, so it cannot be spoofed. It can be changed, read or blocked: T, I and D. An external entity can be spoofed or deny an action: S and R.

A data store can be changed, read, filled up or hold the only log: T, R, I and D. A process can suffer all six. Walking these letters across each part is STRIDE per element.

Try it: count candidate threats

Code: python
letters = {"external entity": "SR", "process": "STRIDE", "data store": "TRID", "data flow": "TID"}
things = [["Student", "external entity"], ["Web app", "process"], ["save order", "data flow"]]
total = 0
for t in things:
    print(t[0], letters[t[1]])
    total = total + len(letters[t[1]])
print("candidate threats:", total)
# Add ["Orders database", "data store"]. How many threats now?

Make a free account to save your work and track your progress.

Check

Have a go

Check

3 questions
Have a go: your answers are marked here and then forgotten. Sign in if you would like your score kept, and to pick up where you left off.Sign in to keep your score

The script asks the questions for you

The lab script holds the canteen model from lesson 1, with its Admin page. It gives each part its letters and turns every letter into a question. Run it to count the candidate threats, then ask for the ones about the card payments.

Write the STRIDE script, part 1

Command
docker exec jupyter sh -c "mkdir -p steps && printf '%s\n' 'import sys' 'letters = {\"external entity\": \"SR\", \"process\": \"STRIDE\", \"data store\": \"TRID\", \"data flow\": \"TID\"}' 'ask = {' '    \"S\": \"Spoofing: can someone pretend to be\",' '    \"T\": \"Tampering: can someone change\",' '    \"R\": \"Repudiation: can someone deny what they did with\",' '    \"I\": \"Information disclosure: can someone read\",' '    \"D\": \"Denial of service: can someone stop\",' '    \"E\": \"Elevation of privilege: can someone gain rights through\",' '}' 'things = [' '    [\"Student\", \"external entity\"], [\"Card payments\", \"external entity\"], [\"Admin\", \"external entity\"],' '    [\"Web app\", \"process\"], [\"Kitchen screen\", \"process\"], [\"Admin page\", \"process\"],' '    [\"Orders database\", \"data store\"],' '    [\"sign in and order\", \"data flow\"], [\"order status\", \"data flow\"], [\"save order\", \"data flow\"],' > steps/stride.py"

Shown here, not run. Press Start lab to type it into your own lab’s terminal.

Write the STRIDE script, part 2

Command
docker exec jupyter sh -c "printf '%s\n' '    [\"orders to cook\", \"data flow\"], [\"payment request\", \"data flow\"], [\"payment result\", \"data flow\"],' '    [\"edit menu\", \"data flow\"], [\"menu changes\", \"data flow\"],' ']' 'threats = []' 'for t in things:' '    for letter in letters[t[1]]:' '        threats.append([letter, t[0]])' 'if len(sys.argv) > 1:' '    word = sys.argv[1].lower()' '    for th in threats:' '        if word in th[1].lower():' '            print(th[0], ask[th[0]], th[1] + \"?\")' 'else:' '    for letter in \"STRIDE\":' '        n = 0' '        for th in threats:' '            if th[0] == letter:' '                n = n + 1' '        print(letter, ask[letter].split(\":\")[0], n)' '    print(\"candidate threats\", len(threats))' >> steps/stride.py"

Shown here, not run. Press Start lab to type it into your own lab’s terminal.

Count the candidate threats

Command
docker exec jupyter python3 steps/stride.py

Shown here, not run. Press Start lab to type it into your own lab’s terminal.

What stride.py printed

LetterCandidate threats
S6
T12
R7
I12
D12
E3
All52

The cells students fill in are left blank in this preview.

Ask about the card payments

Command
docker exec jupyter python3 steps/stride.py payment

Shown here, not run. Press Start lab to type it into your own lab’s terminal.

A common mistake

Warning

Many people think every STRIDE line is a real threat to fix. Each line is a question. "Can someone read payment result?" has a short answer if the flow uses TLS. Answer each question, and keep only the threats you cannot answer yet.

Check

Have a go

Check

3 questions
Have a go: your answers are marked here and then forgotten. Sign in if you would like your score kept, and to pick up where you left off.Sign in to keep your score

Assignment: STRIDE per element

Write STRIDE per element as code.

letters_for(kind) returns the letters for one kind: "SR", "STRIDE", "TRID" or "TID", and "" for anything else. threats(things) takes a list of [name, kind] and returns [letter, name] for every letter of every thing, in order. count_letter(threat_list, letter) counts the threats with one letter.

Code: python
def letters_for(kind):
    # The STRIDE letters for one kind of element, as a string such as "SR".
    return ""


def threats(things):
    # things is a list of [name, kind]. Return [letter, name] for every letter of every thing, in order.
    return []


def count_letter(threat_list, letter):
    # How many threats in the list have this letter?
    return 0

Make a free account to save your work and track your progress.

Exit quiz

Have a go

Exit quiz

5 questions
Have a go: your answers are marked here and then forgotten. Sign in if you would like your score kept, and to pick up where you left off.Sign in to keep your score

Teaching a class? Set this module for your students with a teacher guide, marked assignments and a lab for every student.