Skip to content
AI and Code

How We Use AI to Threat Model an App and Its API

8 min read

We use Anthropic’s Claude models, through Microsoft Foundry and Anthropic’s API, to orchestrate analysis of your telemetry in Azure Log Analytics and your code in GitHub Enterprise Cloud. It forms and tests hypotheses about how your app and API could be misused. Senior engineers set the scope and the rules, triage every result at an approval gate, and test the threat model against your business. No model is trained on your data, and your telemetry stays in Azure UK South.

What is a threat model, and why use AI to build one?

A threat model is a structured view of what could go wrong with a system and what to do about it. The Threat Modeling Manifesto defines threat modelling as analysing representations of a system to highlight concerns about security and privacy, and frames it around four questions: what are we working on, what can go wrong, what are we going to do about it, and did we do a good enough job?

For an app and its API, answering ‘what can go wrong’ well means reading a lot of material: every exposed endpoint and the code behind it, months of telemetry, and the way the business uses the system. That reading is where AI helps most. It can work through code paths and query large volumes of logs far faster than a person, which leaves our engineers more time for the judgement calls that decide what matters.

This sits on top of the baseline, never in place of it. Automated scanning and an independent penetration test find known, generic weaknesses well, and our guide to why a pen test can pass while bots still get in explains the kind of abuse that a white-box layer is for.

What does the AI do, and what do engineers do?

The AI does the reading, querying and drafting, and engineers do the directing and deciding. We split the work like this:

Stage What the AI does What senior engineers do
Scope and rules Works within the scope and rules it is given Set the scope with you, add the business context, and choose which of our rules apply
Hypotheses Proposes ways the system could be misused, based on the code and the context Decide which hypotheses are worth pursuing
Testing Queries the telemetry in Azure Log Analytics and traces code paths in the repository, gathering evidence for or against each hypothesis Check the evidence and the queries behind it
Triage Nothing: this is an approval gate Decide what is real, what matters and what needs more work
Threat model Drafts the threat model from the confirmed findings Test it against how your business works and your priorities
Recommendations Nothing: these are engineers’ decisions Recommend fixes sized to the real risk

The work is iterative. Confirmed patterns become new rules, so each review starts from what earlier reviews taught us.

AI threat modelling for an app and API: scope, hypotheses, testing, engineer triage, threat model, findings, new rules
A six-step loop for AI-assisted threat modelling, with an engineer triage gate. 1, scope and rules: engineers agree the scope with you and set the business context and the rules. 2, form hypotheses: AI proposes ways the app and API could be misused, and engineers choose which to test. 3, test against evidence: AI queries telemetry in Azure Log Analytics and traces code paths for evidence for or against each hypothesis. A senior engineer then triages every result at a gate. 4, threat model: AI drafts it and engineers test it against how the business works and your priorities. 5, recommend: engineers decide the findings and fixes for the report, sized to the real risk. 6, new rules: confirmed patterns can become rules, written by engineers, which feed back into step 1 for later analysis.

How does testing a hypothesis against telemetry work?

A hypothesis is a specific, testable statement about how the system could be misused, and the AI’s job is to find evidence for or against it in the code and the logs.

Take a hypothesis such as ‘accounts are being created in bulk to claim a sign-up reward’. The AI traces the sign-up endpoint through the code, to see what checks exist on account creation and on claiming the reward. It then writes queries against the telemetry in Azure Log Analytics, looking for patterns such as many new accounts from one device or IP range, or bursts of sign-ups that no marketing activity explains. It reports what it found, with the evidence behind it, and an engineer decides whether the hypothesis holds.

Another example is ‘an older version of the API is still being called by something other than our app’. The AI checks which routes the code still exposes, then queries the telemetry for calls to those routes and what made them. An engineer then decides whether the old route needs removing, restricting or simply watching.

Many hypotheses come back with no supporting evidence, and that is useful too, because it tells you where a control is working. What the AI finds is only as good as the telemetry, so if your logs do not record which account, device and app version made each request, that gap becomes one of the findings.

What are the rules, and where do they come from?

The rules are our own, written and maintained by our engineers. They encode what we look for in an app and its API, and they give the AI’s work a consistent starting point that engineers can check and improve. The same experience shapes the rest of our security practice, including our validation of mobile apps against the OWASP Mobile Application Security Verification Standard (MASVS) and our secure coding checks, which include a suite built from the findings of penetration tests on previous projects.

When a review confirms a new pattern of misuse, our engineers can turn it into a rule. That is the main way the method improves over time, and it is our engineers’ work, not model training.

Where are the human gates?

Our engineers stay in control throughout, and the AI does not move work forward on its own. The main gates are:

  • Scope: engineers agree with you what the review covers and what access it needs, and set the rules and context for the AI.
  • Hypotheses: engineers decide which hypotheses are worth testing.
  • Triage: every result is triaged by a senior engineer before it goes any further.
  • Threat model: engineers test the drafted threat model against how your business works and your priorities.
  • Report: engineers decide which findings go in the report and what we recommend.

These gates matter because AI can be wrong. It can propose a hypothesis that does not fit how the system is used, misread a log field or miss a code path, and the gates are where an experienced engineer catches that.

How are client code and data handled?

We handle client code and data as follows:

  • Models: Anthropic’s Claude models (Opus, Sonnet and Haiku), through Microsoft Foundry and through Anthropic’s API.
  • Sources: your telemetry in Azure Log Analytics and your source code in GitHub Enterprise Cloud, with the access agreed with you on the scoping call.
  • No training: we do not train or fine-tune any model on your code, telemetry or other data.
  • Location: your telemetry stays in Azure UK South. Model requests go through our Microsoft Foundry resource in UK South and through Anthropic’s API. For Claude, Microsoft lists Global Standard and Data Zone Standard (US) deployment types, and our Foundry resource uses Global Standard, so model processing may take place outside the UK. Requests through Anthropic’s API are processed by Anthropic under its commercial terms.
  • Controls: our secure software development lifecycle, including access to source code, is governed by our ISO 27001-certified information security management system, and we apply the same controls to AI tooling as to any other system that touches client code. We are also Cyber Essentials Plus certified.

If your contracts require processing to stay in the UK, raise it on the scoping call, before any access is set up. Our guide to Claude on Azure explains the residency options for Claude in more detail.

What are the limits of this approach?

AI-assisted threat modelling makes a white-box review faster and broader, but it has limits:

  • It does not guarantee anything. We describe what we checked and what we found, never that a system is secure.
  • It does not replace a penetration test. We do not carry out penetration testing, and we recommend every client commissions one from a CREST-accredited tester.
  • It depends on the evidence. Gaps in telemetry, or parts of the system outside the agreed scope, limit what the analysis can see, and every report lists what was in and out of scope.
  • It depends on the people. The quality of the outcome rests on the engineers who set the scope, write the rules and triage the results.

How do we approach this?

This method is the core of our mobile and API security review, a white-box review of a live app and the API behind it. We agree the scope and access on a short scoping call, run the analysis with engineers at every gate, and deliver a report with findings ranked by real risk and fixes sized to match. Reviews are fixed price, quoted after the scoping call, and we can make the fixes across the app and the API.

Frequently asked questions

Do you train AI models on our code or data?
No. We do not train or fine-tune any model on client code, telemetry or other data. We use Anthropic's Claude models as they are, and what we build up between reviews is our own set of rules, which our engineers write and maintain.
Which AI models do you use for security reviews?
Anthropic's Claude models (Opus, Sonnet and Haiku), through Microsoft Foundry and through Anthropic's API. They work against your telemetry in Azure Log Analytics and your source code in GitHub Enterprise Cloud, with the access agreed on the scoping call.
Where is our data processed?
Your telemetry stays in Azure UK South. Model requests go through our Microsoft Foundry resource in UK South, which uses Microsoft's Global Standard deployment for Claude, and through Anthropic's API, so model processing may take place outside the UK. If your contracts require UK-only processing, raise it on the scoping call.
Does the AI decide what goes in the report?
No. AI proposes and tests hypotheses, and drafts threat models. Senior engineers triage every result at an approval gate, test each threat model against how your business works, and decide which findings matter and what we recommend.
Can AI threat modelling replace a penetration test?
No. We do not carry out penetration testing, and we recommend every client commissions one from a CREST-accredited tester, alongside automated scanning. AI-assisted threat modelling is an additional white-box layer that uses your code, telemetry and business context.

Ready to transform your software?

Let's talk about your project. Contact us for a free consultation and see how we can deliver a business-critical solution at startup speed.