Demo mode This site is not live. It is currently being tested and developed. Nothing on here represents an offer.
← Exit course SEC-302 Website and E-Commerce Security
Course progress, 0 of 15 parts done0%
Practical work

Table Bay Online's threat model, in four tasks, about 7 hours

Download as PDF

Table Bay Online's asset register, a full data-flow diagram with its boundary crossings, every entry point taken through STRIDE, and a dated one-page threat model for the owner.

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.

The finished shop, as designed

Its routes, each reached as /?r=name, with the module that builds it:

The finished shop's routes
RouteMethodWhat it doesModule
catalogueGETThe product list, the home page0
productGETOne product by its id0
cartGET, POSTView the cart, add or remove an item0
registerGET, POSTMake a customer account2
loginGET, POSTSign in2
logoutPOSTSign out2
accountGETAccount home, signed in only2
ordersGETThe signed-in customer's own orders2
orderGETOne of the customer's own orders2
adminGETThe staff dashboard, staff and admin only2
searchGETProduct search3
admin_productsGET, POSTAdd and edit products, upload a picture, admin only3
imageGETServes a stored product picture by its generated name3
checkoutPOSTCreate a pending order and hand over to the payment page5
payment_returnGETThe customer comes back from the payment page5
payment_webhookPOSTThe payment provider's signed message5
admin_ordersGET, POSTList orders and make an allowed status change, staff and admin5
admin_refundPOSTA refund, admin only5
admin_logGETThe security log, admin only7

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.

  1. 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.
  2. Rank the assets High, Medium or Low by impact, with a one-line reason for each.
  3. 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.

  1. Show every external entity, process and data store, and every data flow between them, each arrow labelled with what moves.
  2. Split the shop's code into at least three processes where it helps: the customer pages, the staff pages and the payment handling.
  3. Mark every trust boundary with a dashed line, including the boundary between customer and staff privilege inside the code.
  4. 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:

  1. Say who can reach it: anyone, a signed-in customer, staff, admin, or the payment provider's server.
  2. 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.
  3. 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.

Model answer: Table Bay Online's asset register
AssetWhere it livesMatters toPropertyImpact of its lossRank and reason
Customers' contact and delivery detailsusers, orders, backupsCustomers, Naledi as information officerConfidentialityHarm to customers, scams that quote real orders, a POPIA notification, lost trustHigh: harm to people and a legal duty
Customers' order historiesorders, order_itemsCustomersConfidentialityReveals what people buy and where they liveHigh: personal information
Admin account (Naledi)users, her sessionNaledi, every customerConfidentiality, integrityOpens every other asset, refunds includedHigh: the master key
Staff account (Jason)users, his sessionJason, customersConfidentiality, integrityOpens orders and customer detailsHigh: wide access to personal information
Customers' password hashesusersCustomersConfidentialitySlow to guess from, but weak passwords could still be found and tried elsewhereHigh: customers reuse passwords
Payments and refunds recordspayments, refundsNaledi, her accountantIntegrityMoney lost or unaccounted forHigh: direct loss
The webhook secretServer configurationNalediConfidentialityFake payment messages that pass as realHigh: hidden, direct loss
BackupsWherever they are keptEveryone aboveConfidentiality, availabilityA full copy of all the above, and the only way back after a disasterHigh: often forgotten, holds everything
Product catalogue and pricesproductsNaledi, makersIntegrityWrong prices charged, wrong products shownMedium: costly but correctable
The ability to tradeServer, code, database, payment linkNaledi, customersAvailabilityLost sales, worried customersMedium: recoverable
The security logsecurity_log, storage/logs/NalediIntegrity, availabilityNo way to show what happened in an incidentMedium: needed when things go wrong
Product picturesstorage/uploads/Naledi, makersIntegrity, availabilityA missing or replaced pictureLow: easily restored from backup
The domain name and its certificateThe domain registrar and the serverNaledi, customersAvailability, integrityCustomers cannot reach the shop, or reach the wrong placeMedium: rare but serious
ReputationCustomers' and makers' mindsNalediAll, through the othersFewer orders, makers leavingMedium: 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.

Model answer: where data crosses a boundary
#FlowWhat crossesThe main risk
1Customer's browser to P1, across B1Addresses with values, form fields, the session cookieEvery value is controlled by whoever runs the browser, so any of it may be wrong or hostile.
2Customer's browser to P1 at the return address, across B1The customer's return from the payment pageIt arrives through the browser, so it proves nothing about payment.
3Customer's browser to the provider's hosted pageCard detailsOutside the shop's boundary entirely. The risk is the shop ever asking for card details itself.
4Provider's server to P3, across B1The signed payment messageA message could pretend to be from the provider, or carry a different amount.
5Staff browser to P2, across B1 and B2Admin forms, status changes, refundsA customer or visitor reaching a staff page, or a staff page reached by a forged request.
6Staff browser to P2 to D2, across B1 and B2Uploaded product picturesA file that is not really a picture, or far too large, ending up where it could be run or fill the disk.
7Supplier feeds to P2 to D1, across B1Product names, descriptions, stockUntrusted text later shown on pages, which must never be treated as markup.
8P4 to the courier's booking API, across B1 outwardsName, delivery address, phone numberPersonal information leaving to an operator: only what a delivery needs, over an encrypted connection, under contract.
9D1 to P1 and P2, inside B1Stored text shown on pagesText stored earlier may have been typed by anyone, so it is encoded when printed.
10Developer and host to the server, across B1 and B3Code, configuration, direct file accessWide 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

Model answer: every entry point of the finished shop through STRIDE
Entry pointWho can reach itThreatsControlsModule
catalogue GETAnyoneD: flooded with requests. T: product text from a feed shown as markup.Hosting limits, encoding every value printed3, 6
product GETAnyoneT: 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 page0, 3, 4
cart GET, POSTAnyoneT: a price or quantity changed in the form. T: a request forged from another site.Prices from the database, a quantity limit, the form token0, 3, 4
register GET, POSTAnyoneE: 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 hashes2
login GET, POSTAnyoneS: 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 staff2
logout POSTSigned inS: 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 token2, 4
account GETSigned-in customerS: 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 required2
orders GETSigned-in customerI: other customers' orders listed.The query asks only for the signed-in customer's orders2
order GETSigned-in customerI: another customer's order shown by changing the id.Fetched by id and owner, so another's order is not found2
admin GETStaff, adminE: 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 details2
search GETAnyoneT 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 sort3
admin_products GET, POSTAdminE: 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 token2, 3, 4
image GETAnyoneI: 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 type3
checkout POSTSigned-in customerT: prices or totals changed. T: a forged request.Prices and totals from the database, a pending order, the form token4, 5
payment_return GETAnyone with a browserS: 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 POSTThe provider's server, and anyone who learns the addressS: 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 work5
admin_orders GET, POSTStaff, adminE: 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 token2, 4, 5, 7
admin_refund POSTAdminE: 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 log2, 5, 7
admin_log GETAdminE: read by staff. I: the log itself holding passwords or card data.Admin role only, never logging secrets or card data2, 7
Supplier feedsThe makers' systemsT: wrong or hostile values. T: descriptions holding markup.Validation of every field, encoding when shown3
Administrative accessPalesa, the hostI: 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 contracts6

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

Table Bay Online web shop: 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.