How to Threat Model a New Feature

Threat modeling helps a team identify what could go wrong while it can still change the design. Start with one feature. Record what it must protect, where the risk arises, which control will address it, and what evidence will show that the control works.

Follow an invoice exportMark where each service takes responsibility for a permission or data-handling decision.
  1. Request

    The portal checks the requester’s billing role and account.

  2. Queue

    The application records the verified account with the job.

  3. Generate

    The worker checks permission and selects approved invoice data.

  4. Deliver

    The application checks current access before serving the file.

  5. Expire

    The download closes and cleanup removes the stored copy.

Describe the feature and who uses it

Pick a concrete action. In a billing portal, a billing administrator might export invoices as a file. Record who may request and retrieve an export, the account whose records it may include, and the approved fields. Bring the people who understand those rules and the relevant application, storage, and access controls.

Identify the start and end of the workflow. For this example, follow the request through the background job, file storage, download, and cleanup. Record assumptions about other roles and systems, such as whether support staff can see exports. Assign an owner and follow-up date when an assumption still needs confirmation.

Map the data flow and trust boundaries

Sketch the actors, services, and stores. For the export, show the browser contacting the application, the application queuing a job, the worker reading authorized invoices, and the application serving the generated file. Mark trust boundaries where the assumptions about identity, permissions, or trust change. At those handoffs, document which component verifies the request or data before relying on it.

Include side effects and copies, such as the temporary file, a notification, and an audit event. Record the permitted audience and retention for each. Ask which decisions can change between steps, including an account membership that ends while an export is queued or before a file is retrieved.

Turn concerns into verifiable requirements

Describe each unwanted outcome in terms the team can recognize. Identify where the control belongs and what evidence will show it works. The invoice export example illustrates four decisions.

Design concern Requirement Evidence to collect
A job starts after the requester loses the billing role. For this feature, require current export permission when the worker begins. Remove the role before the queued job starts in staging and confirm the job ends without creating a file.
An export includes another account’s records or unapproved fields. Scope the worker’s query to the verified account and apply an approved field list. Export synthetic invoices from two test accounts and check each file’s records and fields against the expected set.
Download access outlasts a role change. Check current permission when serving the file through the application. Generate a synthetic export, remove the role, and confirm that the former billing administrator receives the documented denied response.
A generated file stays available past its lifetime. Enforce expiration on retrieval and schedule object cleanup. Confirm the expired synthetic export is unavailable and that cleanup removes the stored object within the agreed window.
Evidence for four export controlsName one observable result for each requirement in the design.
  • Permission at start

    A queued job creates no file after the requester loses the billing role.

  • Account scope

    Each test account sees only its allowed records and fields.

  • Permission at download

    A former billing administrator receives the expected denied response.

  • File lifetime

    An expired export is unavailable and cleanup removes the stored copy.

Decide what needs to happen before release

Give each control and test an owner. Prioritize using the likely impact, the conditions that allow the outcome, and the quality of the evidence. Agree which requirements must pass before release. For any time-limited risk acceptance, record who approved it, the reason, interim measures, and the review date. Write down any open question that could change the decision.

Reopen the model when a change affects the assumptions. For example, allowing external accountants to receive exports or moving downloads to a different service changes who may hold a copy and where access must be checked. Update the affected flow, requirements, and evidence before relying on the earlier decision.

Review authentication and authorization · Prepare for a secure code review

References