A Secure Development Lifecycle for AI — Threat Modelling, Testing, Red Teams, Regulation
You'll be able to:
You can run a threat-modelling session for an AI feature using an established framework, define a pre-release security test plan with automated and human red-team components and a cadence for repeating it, and map a system to the obligations that actually bind it (EU AI Act risk tiers, NIST AI RMF functions, sector rules).
Making security a habit, not a heroic review
Everything in modules 1 to 6 can be done once, by one careful person, for one feature. That does not scale, and it does not survive the next model upgrade. A secure development lifecycle (SDL) for AI is the set of recurring activities that keep the questions being asked as the system changes, so that no release surprises the security team.
Threat modelling as a scheduled activity
Microsoft's guidance on threat modelling AI/ML systems is a practical extension of their general SDL: it adds AI-specific questions to the usual data-flow exercise. Which data sources feed training, and who can write to them? Can the model be queried without authentication? Are outputs consumed by a system that trusts them? Is there a feedback loop where production data becomes training data — and therefore a path for a user to influence future behaviour?
Run the session at design time for every feature that adds a model, a data source, a tool or a new class of user. Fifteen minutes with the data-flow diagram from module 1 and the OWASP list as a prompt catches most of what later testing would find. Record the findings and the accepted risks next to the architecture decision; a threat model nobody can find did not happen.
Testing that runs on every change
Prompts, models and indices change far more often than code, and each change can reopen a closed finding. The test suite should include:
- An adversarial corpus: documents and inputs containing injection attempts, with assertions on what the system must not do (no tool call, no link, no disclosure). This is a regression suite, not a research project; it grows by one case per incident and per red-team finding.
- Output contract tests: structured outputs validate against their schema; free-text outputs are scanned for forbidden patterns (tenant identifiers, secrets).
- Privacy checks on models trained on sensitive data: a membership-inference test (module 4) with a threshold that fails the build.
- Permission tests: each tool is exercised with the agent's actual credentials and must fail outside its scope.
- Behavioural baselines: refusal rates, category distributions and gate frequencies compared with the previous release, so drift is visible early.
Run these in CI on every model swap, prompt edit and index rebuild, with the same seriousness as unit tests.
Red teaming: automated breadth, human depth
Automated red teaming — using one model to generate adversarial inputs for another, as described by Perez and colleagues in 2022 — gives breadth cheaply: thousands of candidate attacks, clustered and ranked, finding failure modes no one thought to test for. It does not replace people. Human red teams find the attacks that require understanding the product and its users: the plausible phishing document, the realistic malicious ticket, the workflow where approval fatigue sets in.
A sustainable cadence: automated red teaming in CI or nightly; a focused human exercise before any launch that adds capability (a new tool, a new data source, a new user class); and a scheduled exercise — quarterly is common — regardless of launches, because the threat landscape moves even when the product does not. Every finding becomes a regression test.
Regulation that actually binds
Security engineers need not be lawyers, but must know which rules change their requirements.
- The EU AI Act classifies systems by risk. Prohibited practices are banned outright; high-risk systems (in areas such as employment, credit, education, critical infrastructure, law enforcement) carry obligations for risk management, data governance, logging, human oversight, accuracy and cybersecurity — explicitly including resilience against data poisoning, model poisoning and adversarial inputs. General-purpose model providers carry separate transparency and, for the most capable models, systemic-risk obligations, phasing in from August 2025. Since the 2026 Digital Omnibus on AI, the high-risk obligations apply from 2 December 2027 for stand-alone (Annex III) systems and from 2 August 2028 for AI in regulated products. If your system is in scope, your threat model, test results and incident logs are evidence you must be able to produce.
- NIST AI RMF is voluntary in the US but widely used as the reference structure (govern, map, measure, manage) and is what auditors and customers ask about.
- Sector rules — healthcare, finance, children's data — apply to AI systems as to any other software, and often force the logging and data-minimisation trade-offs from module 6 to be resolved in a specific direction.
The practical move is one evidence folder per system: threat model, test reports, red-team findings and fixes, model registry entries, incident records. It serves the regulator, the customer security questionnaire and your own post-incident review equally.
Worked example: a security gate on one page
A fictional company adopts four design-review questions: Who can write to anything this model reads? What can this model cause to happen without a human? What leaves the system, and to where? What would we need to show a regulator if this went wrong? Automated tests: adversarial corpus, output contracts, permission tests, behavioural baseline. Pre-launch: a two-day human red-team on the feature's new capability. Quarterly: a half-day exercise on the whole product. Cheap items: the four questions, the baselines. Expensive: the human exercises and membership-inference tests on large models. Marking cost matters because the cheap items run always and the expensive ones are scheduled, not skipped.
What is still unsettled
Guidance on how to meet the AI Act's cybersecurity requirement is still being written through harmonised standards. No benchmark tells you when a system is "secure enough"; red teaming finds problems, it does not certify their absence.
What to remember
- Threat-model at design time for every new model, data source, tool or user class; record the findings where the architecture lives.
- Prompts, models and indices change more often than code; adversarial, contract, privacy, permission and baseline tests must run on every change.
- Automated red teaming for breadth, humans for depth, on a cadence tied to launches and the calendar; every finding becomes a regression test.
- Know your risk tier under the EU AI Act and keep one evidence folder per system.
Check Yourself
Module Mission
30–40 minDecision 7 of the case file. Draft Halden's security gate for any change to Halden Assist: the four questions a feature must answer before design review, the automated tests that run on every model or prompt change, the red-team exercise before launch and each quarter after, and the evidence you would keep for a regulator. Fit it on one page and mark which items are cheap and which are expensive.
Open Case file: Halden Assist →Good looks like
- The four questions can each be answered in a sentence, and one of them is about what the feature can do, not only what it can see.
- The automated tests are concrete (what is run, what fails the build), and at least one comes from an incident in the case file.
- The red-team exercise has a scope, a duration and an owner, and a rule for what happens to its findings.
- The evidence list would let an outsider reconstruct what was tested and when.
- Every item is marked cheap or expensive, and the page says what you would cut first under time pressure.
Loading your work…
Curated Materials
1.6hThe deep work happens here — the lesson is your briefing.
Live on aiqbench
This lesson's subject on the rest of the site, today.
In the news, last 30 days
- Hackers Hide Password-Stealing Malware in GitHub Code, Putting Software Downloads at RiskCybersecurity News ·
- Silver Fox Hackers Use Fake Software Downloads to Spread Gh0stRAT Malware That Can Spy on PCsCybersecurity News ·
- MINE: A Training-Free Defense against Indirect Prompt Injection via Mutual Information and Embedding VariancearXiv ·