Table Bay Online's threat model, in four tasks, about 7 hours
These tasks produce Table Bay Online's threat model, which you use for the rest of the course and review in Module 8. There is no code in this module. You need the lesson, the description of the finished shop below, and a notes file or paper. Keep everything you produce in your course notes, beside the baseline you recorded in Module 0.
Its routes, each reached as /?r=name, with the module that builds it:
| Route | Method | What it does | Module |
|---|---|---|---|
catalogue | GET | The product list, the home page | 0 |
product | GET | One product by its id | 0 |
cart | GET, POST | View the cart, add or remove an item | 0 |
register | GET, POST | Make a customer account | 2 |
login | GET, POST | Sign in | 2 |
logout | POST | Sign out | 2 |
account | GET | Account home, signed in only | 2 |
orders | GET | The signed-in customer's own orders | 2 |
order | GET | One of the customer's own orders | 2 |
admin | GET | The staff dashboard, staff and admin only | 2 |
search | GET | Product search | 3 |
admin_products | GET, POST | Add and edit products, upload a picture, admin only | 3 |
image | GET | Serves a stored product picture by its generated name | 3 |
checkout | POST | Create a pending order and hand over to the payment page | 5 |
payment_return | GET | The customer comes back from the payment page | 5 |
payment_webhook | POST | The payment provider's signed message | 5 |
admin_orders | GET, POST | List orders and make an allowed status change, staff and admin | 5 |
admin_refund | POST | A refund, admin only | 5 |
admin_log | GET | The security log, admin only | 7 |
Its stores: the database data/shop.sqlite (tables products, users, login_attempts, orders, order_items, payments, refunds and security_log, with no column for card data), storage/uploads/ for product pictures and storage/logs/ for logs, all outside the web root.
Its outside parties: the hosted payment provider (its page and its server), the courier's booking API, the supplier feeds from Saltpan Ceramics and Dwarsrivier Linen, Palesa Mokwena (Mokwena Web Studio) as developer, and the company that rents the shop its server.
Task 1: Build the asset register
Extend Table 1 into a full asset register for the finished shop. Go beyond the six groups: split them where the parts differ (customers' details are not the same asset as their password hashes), and add what the table leaves out, such as the product catalogue and its prices, the product pictures, the backups, the logs, the shop's domain name and the server itself.
- For each asset, record where it lives, who it matters to, which of confidentiality, integrity and availability matters most, and what its loss would cost the business in plain words.
- Rank the assets High, Medium or Low by impact, with a one-line reason for each.
- Note any asset the shop deliberately does not hold, and why.
What you produce: an asset register of at least ten assets, ranked, each with its location, who it matters to, the property that matters most, the impact of its loss and the reason for its rank.
How to check: every asset in Table 1 is in your register, every rank has a reason, and someone who has never seen the shop could tell from your register which asset Naledi should worry about most.
Time: 1 hour 15 minutes.
Task 2: Draw the data-flow diagram
Figure 2 is a simplified picture. Draw the complete one for the finished shop, by hand or with any drawing tool.
- Show every external entity, process and data store, and every data flow between them, each arrow labelled with what moves.
- Split the shop's code into at least three processes where it helps: the customer pages, the staff pages and the payment handling.
- Mark every trust boundary with a dashed line, including the boundary between customer and staff privilege inside the code.
- Number each place where data crosses a boundary, and for each write one sentence on what crosses there and the main risk.
What you produce: the diagram and a numbered list of boundary crossings, each with a sentence on its risk.
How to check: the payment result reaches the shop by two separate flows, the card details never cross into the server, and every arrow from outside into the code crosses a dashed line.
Time: 2 hours.
Task 3: Take every entry point through STRIDE
Use the route table above and the outside feeds as your list of entry points. For each:
- Say who can reach it: anyone, a signed-in customer, staff, admin, or the payment provider's server.
- Ask the six STRIDE questions and write each real threat as a short sentence, marked with its letter. Leave out the letters that do not apply.
- Name the control that answers each threat and the module that builds it.
What you produce: a table with one row for each entry point, with columns for who can reach it, its threats by STRIDE letter, the controls and the modules.
How to check: every route in the table appears, every threat has a control, the controls agree with Table 6, and no threat is written as a technique.
Time: 2 hours.
Task 4: Write the one-page threat model
Bring your work together into Table Bay Online's threat model, on one page, for Naledi. Use the checklist in section 6. Rank the entry points by likelihood and impact, choose the three controls you would build first, and argue for each choice in two or three sentences. Record one risk you would accept for launch, with its owner and a date to look at it again.
What you produce: a one-page threat model, dated, ready for Naledi to read and Palesa to build from.
How to check: it fits on one page, every item on the section 6 checklist is there, your three first controls protect your highest-ranked assets, and it names at least one internal risk.
Time: 2 hours.
Show the model answer
Task 1: Build the asset register
Your ranks may differ by a step from these, and that is fine where your reason is sound. What matters is that each asset is separate, located and justified.
| Asset | Where it lives | Matters to | Property | Impact of its loss | Rank and reason |
|---|---|---|---|---|---|
| Customers' contact and delivery details | users, orders, backups | Customers, Naledi as information officer | Confidentiality | Harm to customers, scams that quote real orders, a POPIA notification, lost trust | High: harm to people and a legal duty |
| Customers' order histories | orders, order_items | Customers | Confidentiality | Reveals what people buy and where they live | High: personal information |
| Admin account (Naledi) | users, her session | Naledi, every customer | Confidentiality, integrity | Opens every other asset, refunds included | High: the master key |
| Staff account (Jason) | users, his session | Jason, customers | Confidentiality, integrity | Opens orders and customer details | High: wide access to personal information |
| Customers' password hashes | users | Customers | Confidentiality | Slow to guess from, but weak passwords could still be found and tried elsewhere | High: customers reuse passwords |
| Payments and refunds records | payments, refunds | Naledi, her accountant | Integrity | Money lost or unaccounted for | High: direct loss |
| The webhook secret | Server configuration | Naledi | Confidentiality | Fake payment messages that pass as real | High: hidden, direct loss |
| Backups | Wherever they are kept | Everyone above | Confidentiality, availability | A full copy of all the above, and the only way back after a disaster | High: often forgotten, holds everything |
| Product catalogue and prices | products | Naledi, makers | Integrity | Wrong prices charged, wrong products shown | Medium: costly but correctable |
| The ability to trade | Server, code, database, payment link | Naledi, customers | Availability | Lost sales, worried customers | Medium: recoverable |
| The security log | security_log, storage/logs/ | Naledi | Integrity, availability | No way to show what happened in an incident | Medium: needed when things go wrong |
| Product pictures | storage/uploads/ | Naledi, makers | Integrity, availability | A missing or replaced picture | Low: easily restored from backup |
| The domain name and its certificate | The domain registrar and the server | Naledi, customers | Availability, integrity | Customers cannot reach the shop, or reach the wrong place | Medium: rare but serious |
| Reputation | Customers' and makers' minds | Naledi | All, through the others | Fewer orders, makers leaving | Medium: follows every other loss |
Not held, deliberately: card numbers, card verification values and expiry dates. Customers pay on the hosted payment provider's page, so the shop never receives them, and the database has no column for them. This removes the asset rather than protecting it.
A common mistake is to list "the database" as one asset. The database is where assets live, not an asset in itself: splitting it shows that the password hashes, the contact details and the payment records need different protection.
Task 2: Draw the data-flow diagram
A complete diagram, described in words. Yours will look different, but it should hold the same parts and the same crossings.
External entities: the customer's browser, the staff browser (Jason and Naledi), the payment provider's hosted page, the payment provider's server, the courier's booking API, the supplier feeds, and the developer and the host.
Processes, all inside the server: P1, the customer pages (catalogue, product, search, cart, register, sign-in, account, orders, checkout, payment return). P2, the staff pages (dashboard, products and uploads, orders, refunds, log). P3, the payment handling (the webhook). P4, the delivery booking.
Data stores, all inside the server and outside the web root: D1, the database. D2, the uploads. D3, the logs.
Trust boundaries: B1, the line around the server, which every outside flow crosses. B2, the privilege line inside the code between P1 and P2: a request reaches P2 only with a staff or admin role. B3, the line between the developer's own computer and the live server, which no live customer data should cross outwards.
| # | Flow | What crosses | The main risk |
|---|---|---|---|
| 1 | Customer's browser to P1, across B1 | Addresses with values, form fields, the session cookie | Every value is controlled by whoever runs the browser, so any of it may be wrong or hostile. |
| 2 | Customer's browser to P1 at the return address, across B1 | The customer's return from the payment page | It arrives through the browser, so it proves nothing about payment. |
| 3 | Customer's browser to the provider's hosted page | Card details | Outside the shop's boundary entirely. The risk is the shop ever asking for card details itself. |
| 4 | Provider's server to P3, across B1 | The signed payment message | A message could pretend to be from the provider, or carry a different amount. |
| 5 | Staff browser to P2, across B1 and B2 | Admin forms, status changes, refunds | A customer or visitor reaching a staff page, or a staff page reached by a forged request. |
| 6 | Staff browser to P2 to D2, across B1 and B2 | Uploaded product pictures | A file that is not really a picture, or far too large, ending up where it could be run or fill the disk. |
| 7 | Supplier feeds to P2 to D1, across B1 | Product names, descriptions, stock | Untrusted text later shown on pages, which must never be treated as markup. |
| 8 | P4 to the courier's booking API, across B1 outwards | Name, delivery address, phone number | Personal information leaving to an operator: only what a delivery needs, over an encrypted connection, under contract. |
| 9 | D1 to P1 and P2, inside B1 | Stored text shown on pages | Text stored earlier may have been typed by anyone, so it is encoded when printed. |
| 10 | Developer and host to the server, across B1 and B3 | Code, configuration, direct file access | Wide access to everything, and live data copied into development. |
Check your diagram for the two things learners most often miss: the second, separate flow for the payment result (crossings 2 and 4), and the privilege boundary inside the code (B2). Without B2 the diagram suggests that anyone who reaches the server reaches the staff pages.
Task 3: Take every entry point through STRIDE
| Entry point | Who can reach it | Threats | Controls | Module |
|---|---|---|---|---|
catalogue GET | Anyone | D: flooded with requests. T: product text from a feed shown as markup. | Hosting limits, encoding every value printed | 3, 6 |
product GET | Anyone | T: an id that is not a number reaching the query. I: an error page showing details. | The id checked as a whole number, a prepared statement, a 404 page, a generic error page | 0, 3, 4 |
cart GET, POST | Anyone | T: a price or quantity changed in the form. T: a request forged from another site. | Prices from the database, a quantity limit, the form token | 0, 3, 4 |
register GET, POST | Anyone | E: a role set from the form. S: a weak password. I: revealing which emails have accounts. | Only the expected fields read, role always customer, password rules, slow salted hashes | 2 |
login GET, POST | Anyone | S: guessed or reused passwords. I: different messages revealing accounts. D: flooded with guesses. | The attempt limit, one message for every failure, slow hashes, two-step sign-in designed for staff | 2 |
logout POST | Signed in | S: a session that stays valid after sign-out. T: sign-out forced from another site. | The session destroyed on the server, POST with a form token | 2, 4 |
account GET | Signed-in customer | S: a taken-over session. I: shown to someone not signed in. | HttpOnly and SameSite cookie, a new session id at sign-in, time limits, sign-in required | 2 |
orders GET | Signed-in customer | I: other customers' orders listed. | The query asks only for the signed-in customer's orders | 2 |
order GET | Signed-in customer | I: another customer's order shown by changing the id. | Fetched by id and owner, so another's order is not found | 2 |
admin GET | Staff, admin | E: a customer or visitor reaching it. I: more personal data shown than staff need. | The role checked on the server, a dashboard of counts rather than customer details | 2 |
search GET | Anyone | T and I: search text treated as part of the query. T: the search text shown back as markup. D: a sort column chosen from the address. | A prepared statement, encoding on output, an allow-listed sort | 3 |
admin_products GET, POST | Admin | E: reached by staff or customers. E: an uploaded file run as code. D: very large files. T: a forged request. | The role check, a content check, a size limit, a generated name, storage outside the web root, the form token | 2, 3, 4 |
image GET | Anyone | I: a name that reaches files other than pictures. T: a picture served with the wrong type. | Only generated names accepted, served with its checked content type | 3 |
checkout POST | Signed-in customer | T: prices or totals changed. T: a forged request. | Prices and totals from the database, a pending order, the form token | 4, 5 |
payment_return GET | Anyone with a browser | S: taken as proof of payment. T: values in the address changed. I: order details shown to whoever opens it. | A page that changes nothing and shows only "confirming your payment" | 5 |
payment_webhook POST | The provider's server, and anyone who learns the address | S: a message pretending to be from the provider. T: a changed amount. R: the same payment counted twice. D: many messages. | Signature verification compared safely, amount, currency and reference checked, each payment recorded once, refusal before other work | 5 |
admin_orders GET, POST | Staff, admin | E: reached by customers. T: an order moved to a status it should not reach. R: changes nobody can trace. | The role check, the order's allowed steps, the security log, the form token | 2, 4, 5, 7 |
admin_refund POST | Admin | E: made by staff. T: a refund larger than what was paid. R: "I never made that refund". | Admin role only, refunds bounded by what was paid, who and why recorded, the security log | 2, 5, 7 |
admin_log GET | Admin | E: read by staff. I: the log itself holding passwords or card data. | Admin role only, never logging secrets or card data | 2, 7 |
| Supplier feeds | The makers' systems | T: wrong or hostile values. T: descriptions holding markup. | Validation of every field, encoding when shown | 3 |
| Administrative access | Palesa, the host | I: secrets in the code or in version control. E: the server run with more rights than it needs. I: live data copied to development. | Secrets in an uncommitted environment file, least privilege, development and live kept apart, written operator contracts | 6 |
If your table names a technique anywhere, rewrite that cell as what could go wrong. If a row has a threat with no control, that is a gap in the design: say which module should close it. Two rows people often skip are logout, because signing out seems harmless, and payment_return, because it looks like the payment itself.
Task 4: Write the one-page threat model
Scope. The relaunched web shop as designed, on its rented server, with its payment provider, courier, supplier feeds, developer and host. Made with Naledi Mahlangu, Jason Petersen and Palesa Mokwena. Version 1, on the first day of the review. To be reviewed before launch, and whenever a feature or outside party is added.
Assets, ranked. High: customers' personal information (harm to people, POPIA), admin and staff accounts (keys to everything), payment and refund records (money), the webhook secret (fake payments), backups (a full copy). Medium: the catalogue and prices, the ability to trade, the security log, the domain. Low: product pictures. Card data is not held: customers pay on the provider's page.
Actors. Visitors, customers, Jason (staff), Naledi (admin), the payment provider's server, the courier's API, supplier feeds, Palesa and the host. Operators under POPIA section 21: the host, the payment provider, the courier and Palesa, each needing a written contract with security measures. Internal risks: a signed-in customer reaching others' orders, a staff account used by someone else, and honest mistakes such as a mistyped refund.
Boundaries. See the data-flow diagram, crossings 1 to 10. The two that matter most: the payment result arrives by two flows, and only the signed webhook is trusted. The staff pages sit behind a privilege boundary inside the code.
Entry points, ranked. 1. The order pages: another customer's order shown (High impact, High likelihood): fetch by id and owner, Module 2. 2. Sign-in: staff passwords guessed or reused (High, High): attempt limit, slow hashes, two-step designed, Module 2. 3. The webhook: a pretend payment message (High, Medium): signature, amount and reference checks, Module 5. 4. Search and forms: text treated as a query or as markup (High, Medium): prepared statements and encoding, Module 3. 5. Uploads: a file run as code (High, Medium): content check, generated name, outside the web root, Module 3. 6. Every form: forged requests (Medium, High): form token, Module 4. 7. Errors and configuration (Medium, Medium): generic error pages, safe settings, Modules 4 and 6. 8. Afterwards: nobody can show what happened (Medium, Medium): security log and alerts, Module 7.
Build first. (1) Ownership checks on every order query and role checks on every staff page: they protect the two highest-ranked assets, any signed-in customer could find the gap by accident, and they are cheap to build now and expensive to retrofit. (2) The webhook signature and amount checks: a pretend payment message would cost money silently, and the rule "only the verified webhook marks an order paid" shapes the whole checkout, so it must be settled before checkout is built. (3) Prepared statements and output encoding in search and forms: these are the places any visitor can type into, and the fix is a habit that must be in place before the code grows.
Accepted for launch. Two-step sign-in for staff and admin is designed but its code check is a stub. Owner: Naledi (decision), Palesa (build). Meanwhile staff use long unique passwords from a password manager and the attempt limit applies. Review: one month after launch.
Review triggers. A new feature, such as a supplier price import page. A new outside party. Any incident. Otherwise every six months.
Check your page against three tests. Do your first three controls protect your highest-ranked assets? Have you named an internal risk, not only outsiders? Does your accepted risk have an owner and a date? The commonest weakness in a first threat model is the second: a page about hackers that forgets the signed-in customer and the staff laptop.