Chapter 3: Threat Modeling on Paper
3.4 A payment gateway on paper
Draw four parts. No more, for this lesson.
- External entity: the mobile app user. A person outside your system, holding a phone.
- Process: the payment API. The box that decides what to do with a payment request.
- Data store: a Postgres database of balances. The memory of who has what.
- Data flow: the request travels over HTTPS from the phone to the payment API.
Read the picture in order.
- The user starts on the phone, outside the API.
- The phone sends a payment request.
- The arrow is HTTPS. That means the lesson expects encryption in transit. A team that allows a plain, unprotected request has already dropped a fix.
- The payment API is the only process in this small picture.
- The API reads and writes balances in Postgres.
- The database is a data store, not a person. It does not "decide." The API decides.
What is deliberately missing: card-network internals, bank cores, and admin tools. Scope from PASTA step 2 says we do not pretend those boxes are ours today. You can write "neighbor" in the margin and leave them undrawn.
Suppose we are looking at an Indian payment API. The user owes Rs 5000. The phone should ask the API to collect that order's amount. The API should look up the order in its own data, not accept a random total from the device. The database stores balances. It should change only after the API has agreed the amount.
A tiny number on the picture, still a teaching example: the order total is 5000. A wrong body says 1. Those two integers are the whole drama. 5000 − 1 = 4999. That gap is the money the merchant would lose if the server believed the phone. You do not need a larger formula.
Practice task
Draw the four parts on paper. Label each one with the words external entity, process, data store, or data flow. Put 5000 on the honest arrow and 1 beside it in brackets labeled "feared change." Stop. Do not add tools, commands, or extra boxes.