Mini project: ShopLite threat model
60 min · Beginner
Need help? Ask a tutor on WhatsApp (opens in a new tab)A threat model is a short written answer to three questions about a system: what are we protecting, who might attack it and how, and what will stop them. Writing it before any security code turns "make it secure" into a list of exact rules that can be built and tested.
What you'll build
You start from shoplite-api as the Spring Data JPA section left it: all 26 endpoints of the ShopLite API contract (API-DESIGN.md) on Spring Boot 4.1 with MySQL, Problem Details errors and fixed N+1 queries, and no security at all. Today anyone who can reach the server can change prices, read every customer and ship any order.
No code is written in this project. You write SECURITY.md, the security contract for the rest of this section: the users and the data, the trust boundaries, an access table for every endpoint (including the new /api/v1/auth/... and /api/v1/me/... endpoints), the 401 and 403 error types, and every risk with its OWASP 2025 category and the defence a later module builds. You commit it on a branch of shoplite-api and open a pull request.
GET /api/v1/products/6 no token -> 200 public catalogue
PATCH /api/v1/products/6 {"price": 1.00} no token -> 401 unauthorized
PATCH /api/v1/products/6 {"price": 1.00} Asha (CUSTOMER) -> 403 forbidden
GET /api/v1/me/orders Asha (CUSTOMER) -> 200 her orders 10, 3, 1
GET /api/v1/orders/14 Asha (CUSTOMER) -> 404 order 14 is Ravi's
GET /api/v1/orders/14 admin -> 200 admins read any order
POST /api/v1/me/orders {"addressId": 3, ...} Asha (CUSTOMER) -> 422 address 3 is Ravi's
POST /api/v1/auth/register {..., "role": "ADMIN"} no token -> 400 unknown field "role"Requirements
- 1
SECURITY.mdlists the users (guest, customer, admin, attacker) and every kind of data with its sensitivity and rule. - 2A trust-boundary line shows where HTTPS starts and states that every client value is untrusted and identity comes only from the token.
- 3The access table covers every contract endpoint plus
POST /api/v1/auth/register,POST /api/v1/auth/loginand the/api/v1/me/...endpoints, with the answer for a guest, a customer and an admin. - 4Other customers' orders answer 404, admin endpoints answer 401 without a token and 403 for customers, and anything not in the table is denied.
- 5The error table adds the
unauthorized(401) andforbidden(403) Problem Details types to the contract. - 6Every risk has an OWASP 2025 category, a concrete defence and the module that builds it; at least password storage, order access by id, admin actions, trusted body fields and tokens in transit are covered.
- 7
SECURITY.mdand an updatedREADME.mdare committed on a branch ofshoplite-apiwith a pull request.
Milestones
0/5 done · commit and push after each oneList ShopLite's users, data and endpoints
Sections 1 to 3 of SECURITY.md name every user, every kind of data and the trust boundaries.
Decide who may call each endpoint
The access table gives a guest, a customer and an admin answer for every endpoint.
Find the risks
A numbered list of risks, each with its OWASP 2025 category.
Plan a defence for every risk and define the errors
Every risk has a concrete defence and a module, and the 401/403 error types are written down.
Check the table with requests and open a pull request
Every sample request has one clear answer from SECURITY.md alone, and the pull request is open.
Build it in your own GitHub repository and push after each milestone. When everything works, mark the project as complete.
Extra challenges (optional)
Do any you like, each on its own branch, so your main project keeps working.
Add a DELIVERY role for delivery partners: they may read only the address and items of SHIPPED orders and mark them delivered. Add the rows and any new risk.· easy
Add a rate-limit table: how many login attempts, sign-ups and order placements per minute you allow per account and per IP address, and what the response is when the limit is hit.· medium
Threat-model a new feature before it exists: discount coupons (an admin creates them, a customer applies one at checkout). List the abuse cases and the server rules that stop them.· hard
Solution
Opens when you add your repository link.
Finish up
Mark complete & continue
Next: Adding the starter and the default login