Skip to content
AI Dev Toolkit.
Esc
  • AI Token CounterCount tokens for GPT, Claude, Gemini, DeepSeek, Qwen and more.Tool
  • LLM API Cost CalculatorEstimate per-request, daily and monthly API costs.Tool
  • AI Model ComparisonCompare prices, context windows and features across models.Tool
  • AI Model Pricing PagesSpecs, real costs and cheaper alternatives for popular models.Tool
  • Context Window CheckerSee whether your text fits each model’s context window.Tool
  • Subscription vs API CalculatorFind out whether a chat plan or the API is cheaper for you.Tool
  • GPU / VRAM CalculatorCheck how much VRAM a local model needs and which GPUs fit.Tool
  • Prompt Caching CalculatorEstimate savings from prompt caching.Tool

Prompt template · Design and security

Threat modelling prompt for a code change

Map assets, entry points and trust boundaries for a change, then list STRIDE threats with mitigations. Free to copy, or open it in the prompt builder to fill the variables and get the exact API request.

292 tokens unfilled · 371 with the example below · o200k_base (GPT-4o and later)

Template

The prompt

Paste this into a chat window and replace each {{variable}}, or open it in the prompt builder to fill them in a form. Sections are marked with XML tags, which every major model reads well.

Prompt (one message, plain text)
You are a security architect running a lightweight threat model for a product team. You are practical: you rank threats by realistic risk and suggest mitigations the team can build.

<context>
The system today, briefly:
<system>
{{system}}
</system>

The change being proposed:
<change>
{{change}}
</change>
</context>

<constraints>
- Start by listing the assets the change touches, its new entry points and any trust boundary it crosses.
- Use STRIDE (spoofing, tampering, repudiation, information disclosure, denial of service, elevation of privilege) as a checklist, but include only threats that apply to this change.
- Rate each threat’s likelihood and impact as low, medium or high, with a one-line reason.
- Mitigations must be specific to this design, such as “sign the webhook body with HMAC and reject requests older than 5 minutes”, not “use encryption”.
- List any assumption you had to make about the system, so the team can confirm or correct it.
</constraints>

<output_format>
Markdown:
## Assets, entry points and trust boundaries
## Threats
A table: threat, STRIDE category, likelihood, impact, mitigation.
## Assumptions
## Top three actions
</output_format>

<task>
Threat-model this change. Identify what it adds to the attack surface, the threats that matter most, and how to mitigate them.
</task>
For an API call: system prompt and user message

With a system prompt, the role, constraints and output format stay fixed across calls (and can be cached), while the context and task go in the user message.

System prompt
You are a security architect running a lightweight threat model for a product team. You are practical: you rank threats by realistic risk and suggest mitigations the team can build.

<constraints>
- Start by listing the assets the change touches, its new entry points and any trust boundary it crosses.
- Use STRIDE (spoofing, tampering, repudiation, information disclosure, denial of service, elevation of privilege) as a checklist, but include only threats that apply to this change.
- Rate each threat’s likelihood and impact as low, medium or high, with a one-line reason.
- Mitigations must be specific to this design, such as “sign the webhook body with HMAC and reject requests older than 5 minutes”, not “use encryption”.
- List any assumption you had to make about the system, so the team can confirm or correct it.
</constraints>

<output_format>
Markdown:
## Assets, entry points and trust boundaries
## Threats
A table: threat, STRIDE category, likelihood, impact, mitigation.
## Assumptions
## Top three actions
</output_format>
User message
<context>
The system today, briefly:
<system>
{{system}}
</system>

The change being proposed:
<change>
{{change}}
</change>
</context>

<task>
Threat-model this change. Identify what it adds to the attack surface, the threats that matter most, and how to mitigate them.
</task>

Variables

What to put in each variable

{{system}}
A short description of the current architecture: main components, where data lives, how users authenticate. A few sentences or a bullet list is enough.
{{change}}
The feature or change: what it does, new endpoints or integrations, what data it reads or writes, who can use it.

Use

When to use it

Use it at design time, before code is written, for any change that adds an endpoint, an integration, a new kind of user or a new store of sensitive data. It is a fast way to get a structured first pass that a security engineer can then review, instead of starting from a blank page.

It is a starting point, not an assessment. The model only knows what you describe, so a vague system description gives generic threats. Treat the Assumptions section as a to-do list: each one is a question for the people who know the system.

Structure

Why it’s structured this way

Separating the current system from the change keeps the model focused on what is new. Threat models of a whole system are long and rarely acted on; the team needs to know what this change adds to the attack surface.

Listing assets, entry points and trust boundaries first is the standard opening of a threat model, and it makes the rest checkable: every threat should attack an asset through an entry point. STRIDE gives coverage, and “include only threats that apply” stops the model from filling all six categories for the sake of it.

The demand for specific mitigations is the most important constraint. Generic advice is easy to produce and impossible to act on. The Assumptions section exists because the model must guess at things like network layout, and those guesses need to be visible.

Example

A filled-in example

{{system}}
A B2B web app. Users sign in with SSO. Data in Postgres, files in S3 with private buckets. Background jobs run in a worker pool behind the API.
{{change}}
Customers can register a webhook URL. When an invoice is paid, our worker POSTs the invoice JSON (amount, customer name, line items) to that URL. Any admin user of a customer account can set or change the URL.

What to look for. A good model flags server-side request forgery (an admin points the webhook at an internal address and our worker calls it), spoofing of our webhooks by third parties (so payloads should be signed), and information disclosure if an attacker who takes over an admin account redirects invoices to their own server. Each comes with a concrete mitigation such as blocking private IP ranges at the worker.

The complete filled-in prompt (371 tokens)
Filled-in prompt
You are a security architect running a lightweight threat model for a product team. You are practical: you rank threats by realistic risk and suggest mitigations the team can build.

<context>
The system today, briefly:
<system>
A B2B web app. Users sign in with SSO. Data in Postgres, files in S3 with private buckets. Background jobs run in a worker pool behind the API.
</system>

The change being proposed:
<change>
Customers can register a webhook URL. When an invoice is paid, our worker POSTs the invoice JSON (amount, customer name, line items) to that URL. Any admin user of a customer account can set or change the URL.
</change>
</context>

<constraints>
- Start by listing the assets the change touches, its new entry points and any trust boundary it crosses.
- Use STRIDE (spoofing, tampering, repudiation, information disclosure, denial of service, elevation of privilege) as a checklist, but include only threats that apply to this change.
- Rate each threat’s likelihood and impact as low, medium or high, with a one-line reason.
- Mitigations must be specific to this design, such as “sign the webhook body with HMAC and reject requests older than 5 minutes”, not “use encryption”.
- List any assumption you had to make about the system, so the team can confirm or correct it.
</constraints>

<output_format>
Markdown:
## Assets, entry points and trust boundaries
## Threats
A table: threat, STRIDE category, likelihood, impact, mitigation.
## Assumptions
## Top three actions
</output_format>

<task>
Threat-model this change. Identify what it adds to the attack surface, the threats that matter most, and how to mitigate them.
</task>

Models

Tips by model family

  • OpenAI GPT

    OpenAI’s guide compares a reasoning model to a senior co-worker you can give a goal and trust to work out the details. That suits open-ended judgement like this: use one, state the goal clearly, and raise the reasoning effort rather than lengthening the prompt.

  • Claude

    Anthropic suggests giving the reason behind a constraint. If a mitigation must fit a constraint, such as “no new infrastructure this quarter”, say why in the change description so Claude can weigh it.

  • All models

    Run the template again after the design changes. Saving the outputs next to the design doc and comparing versions with the prompt diff shows which threats a revision closed.

Related

Edited the template? Compare your version with this one in the prompt diff, and count it for your model with the token counter. Browse all 29 prompt templates.