Red-teaming, threat modelling and governance

Structured adversarial testing, a threat model for LLM systems, and the policies, records and oversight that keep a deployment defensible.

Expert about 5 h

The picture

  1. 01

    Threat model

    assets, actors

  2. 02

    Attack corpus

    categories

  3. 03

    Automate

    tools, CI

  4. 04

    Triage

    severity, owner

  5. 05

    Govern

    policy, audit

Red-teaming is structured, not random

Red-teaming means deliberately attacking your own system to find failures before others do. Done well it is a repeatable process with scope, categories, severity and follow-up, not a one-off afternoon of clever prompts.

Start with a threat model

Answer, in writing:

  1. Assets: what is worth protecting (customer data, credentials, brand, money, safety)?
  2. Actors: who might attack (curious users, competitors, fraudsters, insiders), and who might be harmed?
  3. Entry points: chat input, uploaded files, retrieved documents, tool outputs, MCP servers, fine-tuning data, logs.
  4. Capabilities: what can the system do (tools, permissions, network)?
  5. Threats per entry point and mitigations for each.
Entry point: uploaded PDF in RAG corpus
Threat:      indirect prompt injection steering the answer or a tool call
Impact:      wrong guidance, data exfiltration via links (HIGH if tools attached)
Mitigation:  isolate as data; no tools on this prompt; strip links; citation check; ingestion scan
Test:        tests/attacks/pdf_injection.py (in CI)
Owner:       platform team   Review: quarterly

Attack categories to cover

  • Prompt injection (direct and indirect) and instruction hijacking.
  • Data exfiltration: system prompt, other users' data, secrets, memory contents.
  • Tool abuse: unauthorised actions, privilege escalation, SSRF, path traversal, destructive commands.
  • Jailbreaks and policy evasion (role-play, encoding tricks, multi-turn escalation).
  • Harmful or biased output relevant to your domain.
  • Denial of wallet: inputs engineered to burn tokens or tool calls.
  • Supply chain: malicious packages, models, datasets, MCP servers.
  • Data poisoning of retrieval corpora, memories or fine-tuning sets.

Automate what you can

# garak: probe a model endpoint with many attack families
python -m garak --model_type openai --model_name gpt-4o-mini --probes promptinject,dan

Scanners give breadth; they will miss application-specific logic, so combine them with hand-written scenarios from your threat model. Use an LLM to generate attack variants, then keep the successful ones in a regression corpus.

Run a scoring script that records for each attack whether it succeeded, how severe the consequence would have been, and which control stopped it.

Triage and fix

Rate each finding by impact × likelihood, assign an owner and a deadline, and fix the class of problem, usually by architecture (remove a privilege, add an approval, isolate a reader), not by adding another sentence to the prompt. Add a regression test for every fix.

Governance: the paper trail that protects you

  • Risk register: risks, ratings, owners, mitigations, residual risk, review dates.
  • System or model card: purpose, intended and out-of-scope uses, data, evaluation results (with slices), known limitations, human-oversight arrangements.
  • Change control: prompts, models, tools and policies are versioned and reviewed; evaluation results are attached to each release.
  • Human oversight: where a person reviews or can override, and how that is recorded.
  • Incident response: how to disable the system or a tool quickly, who is on call, how users are told.
  • Records and retention: what is logged, who can read it, how long it is kept, how deletion requests are handled.
  • Regulatory mapping: check which rules apply to your use case and region (for example the EU AI Act's risk categories) and with whom to confirm. This is a place to involve legal and compliance colleagues early.

The NIST AI RMF organises this as four functions, Govern, Map, Measure, Manage, which is a useful checklist even for a small team.

Common mistakes

  • Treating red-teaming as a launch checkbox instead of a continuing practice.
  • Fixing each finding with another prompt instruction.
  • No kill switch.

Exercises

  1. Write the threat model for one of your systems and list five tests that come out of it.
  2. Run a scanner against a test endpoint, triage the findings, and fix one at the architecture level.

You are done when you can…

  • Write a threat model for an LLM system listing assets, attackers, entry points and mitigations
  • Run an automated scanner against your endpoint and triage the findings
  • Produce a risk register and a model/system card for a deployment