Threat modelling an AI feature
Before you build, draw how data flows, mark where trust changes, and ask what could go wrong. Here is a practical method for AI features.
In 60 seconds
Threat modelling an AI feature
Before you build, draw how data flows, mark where trust changes, and ask what could go wrong. Here is a practical method for AI features.
Step 1: draw the data flow
[Customer browser]
| question
======|================= trust boundary: internet -> our app
v
[App server] --reads--> [Order DB]
| system prompt + question + retrieved help pages
======|================= trust boundary: our app -> model provider
v
[Model API] --proposes tool call--> [App server]
|
======|================= trust boundary: model output -> our actions
v
[Refund tool] [Logs]Step 2: name the assets
| Asset | Example | What would hurt |
|---|---|---|
| Data | Order history, addresses, internal help pages | One customer sees another's data |
| Money | Refunds, your model API bill | Fake refunds, a huge bill |
| Actions | Refund tool, sending email, changing an order | The bot does something nobody asked for |
| Trust and reputation | Answers that customers screenshot and share | The bot promises a fake offer or says something offensive |
Step 3: STRIDE, adapted for AI features
| Threat | Classic meaning | In an AI feature |
|---|---|---|
| Spoofing | Pretending to be someone else | Text in a document claims to be the system or an admin; a user claims "I am the manager" |
| Tampering | Changing data or code | Poisoned help pages in the knowledge base; an edited prompt template |
| Repudiation | Denying you did something | No record of which prompt and which retrieved text led to a refund |
| Information disclosure | Leaking data | The bot shows another user's order, the system prompt or a confidential document |
| Denial of service | Making it unavailable | Huge inputs, agent loops, or cost abuse that uses up the budget |
| Elevation of privilege | Getting powers you should not have | A user makes the model call a tool they cannot call directly (a confused deputy) |
Step 4: write abuse cases
- "As a customer, I type another customer's order number and claim to be staff, so that I can see their address."
- "As an outsider, I post a product review with hidden instructions, so that the bot tells other users to pay on a fake UPI ID."
- "As a bot operator, I script thousands of long questions to a free chatbot, so that I get free model use at the shop's cost."
Step 5: controls, owners and follow-up
- 1
Rank
For each abuse case: how likely, how bad? Start with the worst. - 2
Choose controls
Prefer controls in code and data access: permission checks, limits, approvals. - 3
Assign owners
Every control gets a person and a date. - 4
Turn into tests
Each abuse case becomes a test case you can run again. - 5
Revisit
New tool, new data source, new model or new users: update the model.
Watch and read more
Lab
A one-page threat model for a small AI support bot, on paper or in a document.
The problem
The feature: a chat support bot for a small online saree shop. It answers questions from the shop's help pages, can look up the status of the logged-in customer's orders, and can issue refunds up to ₹500.
- Draw the data flow. Include the browser, app server, order database, help pages, model API, refund tool and logs. Mark every trust boundary.
- List the assets: data, money, actions, reputation.
- Write one STRIDE threat for each of the six letters.
- Write three abuse cases in the form "As a …, I …, so that …".
- Pick your top three threats and write one control and an owner for each.
You are done when
Hard questions
Try to answer before you reveal. If you can answer these, you understood the lesson.
Q1Why draw a trust boundary between the model and your tools, when both run inside your own system?Reveal
Because the model's output is shaped by text you do not control: user messages, retrieved documents, product reviews. So a tool call proposed by the model may really be an attacker's request. The tool code must check identity, ownership and limits itself, exactly as it would for a request from the internet.
Q2Your threat model lists the control "the system prompt tells the bot never to refund more than ₹500". What is wrong, and what is the fix?Reveal
That is a request to the model, not a control. The model can be talked out of it, or tricked by injected text. The fix is a check inside the refund tool: reject any amount above ₹500 or above the order value, and confirm the order belongs to the logged-in user. The prompt line can stay for a better user experience, but it is not what keeps you safe.
Questions people ask
How long does a threat model take?
For one small feature, an hour with the right people is often enough for a useful first version. A big platform needs more. A short model that is actually used is better than a perfect one nobody reads.
Who should be in the room?
Someone who knows the design, someone who writes the code, someone from security, and ideally someone from product or support who knows how real users behave. Support staff often know the abuse cases already.
Do we need a special tool?
No. A whiteboard, a shared document or pen and paper works. Tools can help with larger systems, but the thinking matters more than the tool.
What is the difference between MITRE ATLAS and MITRE ATT&CK?
ATT&CK catalogues attacker behaviour against ordinary IT systems. ATLAS focuses on attacks against AI and machine learning systems. For an AI feature you will often use both, because the app around the model is still ordinary IT.
Lesson test
5 questions. Get 3 right (60%) to pass and complete this lesson.