Guide · AI security
How to red team an LLM application
To red team an LLM application, start from the damage the application could do in its real setting and work back to the attacks that would cause it. Test the deployed application, not only the model, including every place untrusted text enters. Probe by hand first, then automate. Run each attack more than once, and test again after every fix.
Last reviewed
This guide applies AI red teaming to one application built on a language model.
Start from the damage, not from a jailbreak list
Pick the outcomes you cannot accept before you pick a single attack. Microsoft’s AI red team, reporting on more than 100 generative AI products, says that “Starting from potential downstream impacts, rather than attack strategies, makes it more likely that an operation will produce useful findings tied to real world risks”. Work backwards from each outcome to the paths an attacker could take.
Two questions set those outcomes: what the application can do, and where it is used. Microsoft’s example is the same model used either as a creative writing assistant or to summarise patient records. The second “clearly poses much greater downstream risk”. An assistant that can send email, run code or read other users’ data has more to lose than one that only chats.
Then write the scope down. OWASP’s GenAI Red Teaming Guide says it should name “which models and systems will be tested, what types of tests will be conducted, and what areas or activities are explicitly excluded”. Its rules of engagement include where testing runs, who to escalate to, how test data is handled, how to roll back, and who has given permission.
Attack the application, not only the model
A model that holds up on its own can still sit inside an application that does not. Microsoft warns that “red teaming strategies that target only models may not translate into vulnerabilities in production systems”, and that strategies ignoring the components that are not generative AI, such as “input filters, databases, and other cloud resources”, “will likely miss important vulnerabilities”. In one of its case studies the flaw was an outdated FFmpeg library in a video-processing app. A crafted video file could make the server reach internal resources, a server-side request forgery. No prompt was involved.
OWASP splits the work into layers you can test one at a time:
- the model: alignment, robustness and bias, plus where the model came from: provenance, malware in the model, and the training data pipelines
- the implementation: getting past supporting guardrails, such as those “included in a system prompt”, poisoning the data a retrieval augmented generation pipeline retrieves, and testing controls such as model firewalls and proxies
- the system: the components around the model, excessive agency and the supply chain
- runtime: business processes, over-reliance and social engineering
Test where users are. Microsoft’s planning guide says to test “on the production UI as much as possible because this most closely resembles real-world usage”, and to say in the report which endpoint each result came from. A result from the raw model API does not tell you what your AI guardrails and system prompt do.
Go where untrusted text gets in
Content the application reads but the user did not type is attack surface too. Indirect prompt injection puts the attack there. Microsoft’s examples are documents in a retrieval pipeline and an email that a copilot summarises, and it says hiding instructions in documents has let it “alter model behavior and exfiltrate private data” in “a variety of operations”. Plant test instructions in each channel the application reads, not only in the chat box.
Then chain the steps. One Microsoft operation used prompt injections written in a low-resource language, one with little text available for training, to discover the app’s internal Python functions. A second injection, carried in content the app read, got the model to write a script calling those functions. Running that script pulled out private user data. Microsoft notes that these injections “were crafted by hand and relied on a system-level perspective”.
OWASP’s prompt injection entry gives the stance to test from: treat “the model as an untrusted user” and check whether trust boundaries and access controls hold when it misbehaves.
Probe by hand, then automate what you learned
Microsoft’s planning guide calls for “an initial round of manual red teaming before conducting systematic measurements”. Start open-ended, with testers free to report anything that goes wrong. Turn what they find into a list of harms, then run guided rounds against the list and add new harms as they appear. Mix testers who think like attackers with ordinary users who had no part in building the app, and give security specialists the jailbreaking and system prompt extraction work.
Automation comes after. Anthropic describes experts first probing by hand, then standardising their attacks, and then using a language model “to generate hundreds or thousands of variations of those inputs”. Open-source frameworks exist for this. Microsoft’s PyRIT supplies prompt datasets, prompt converters such as encodings, automated attack strategies and scorers. garak, from Derczynski and colleagues, runs probes that are each “designed to elicit a single kind of LLM vulnerability”.
Keep a person in the loop. Microsoft says these tools “should not be used with the intention of taking the human out of the loop”. Using a model to score outputs works for simple checks, but it is “less reliable” in medicine, cybersecurity and chemical, biological, radiological and nuclear (CBRN) weapons, where only subject matter experts can judge the output. garak’s authors say it is “designed to be used as part of human assessment”, and that it “does not deal with security issues presenting in a broader system context, such as code execution or insufficient access controls”.
Run every attack more than once
The same prompt can fail and then succeed. OWASP says “a prompt that fails initially may succeed upon repeated attempts”, so it recommends several attempts per attack and a success threshold based on repeated trials. For prompt injection OWASP sets a lower bar: “a single successful adversarial response may indicate a vulnerability”, though it is worth confirming it reproduces. Microsoft makes the same point about scale: running attacks in volume helps “estimate how likely a particular failure is to occur”.
Record enough to rerun each finding. Microsoft’s guide lists the date, a unique ID for the input and output pair where one is available, the prompt, and a description or screenshot of the output.
What the report can and cannot claim
One finding shows that a failure can happen. On its own it does not show how common the failure is. Microsoft’s planning guide says red teaming is “not a replacement for systematic measurement”, and warns: “It is important that people do not interpret specific examples as a metric for the pervasiveness of that harm.” Repeating an attack gives a rough rate for that attack. The guide treats red teaming as the step that produces the list of harms to measure and mitigate next. garak’s authors make a related point about their own tool: “It would be pointless to attempt to treat garak results as a benchmark”, because the framework “is customizable in each run” and its output “would (and should) vary for different contexts”.
Retest after every fix. Microsoft’s planning guide says to test with and without the mitigations in place, and the AI red teaming topic covers why the loop never ends. A clean run proves only that these testers found nothing with these attacks on this version.
Sources
- Lessons From Red Teaming 100 Generative AI ProductsMicrosoft, via arXiv, 13 Jan 2025
- Planning red teaming for large language models (LLMs) and their applicationsMicrosoft Learn, 13 May 2026
- GenAI Red Teaming Guide, Version 1.0OWASP GenAI Security Project, 23 Jan 2025
- LLM01:2025 Prompt InjectionOWASP GenAI Security Project
- garak: A Framework for Security Probing Large Language ModelsarXiv, 16 Jun 2024
- Challenges in red teaming AI systemsAnthropic, 12 Jun 2024
Related topics
Terms in this guide
In the news
- In tests, 62 of 72 AI agent incidents with damage had no attacker
- Test finds that Claude Fable 5.2 knows rare protein sequences
- Microsoft releases Cowork browsing, but agent identity is in preview
- BELLS-O tests 33 AI safety filters for speed and cost
- Two Granite 4.1 preview models use tags against prompt injection
- Deepfake detectors that read a pulse signal learn the video source
- ArmedAgent test finds safety risks when coding agents move robot arms
- Test shows that defenses miss attacks on the decisions of AI agents
- Researchers bypassed ChatGPT Lockdown Mode through HTML preview
- Study names 9 types of prompt injection attack
- CrowdStrike agrees to buy 2 AI startups and adds a kill switch
- CrowdStrike will buy Dreadnode to test AI agents before launch
- Wandhöfer tells that AI agents break payment authentication
- Agents that change from feedback obey attackers more frequently
- One short suffix flips 43% of unseen documents for the Jev model
- Terra has less high-severity flags but more small flags in OpenAI tests
- Attacks change 46.3% of correct answers by the Jev decision model
- Attacks that keep answers almost correct have more success on 7 models
- A 2015 network beat two top AI models on skin lesions, 62% to 42%
- Anthropic tells companies to use one agent, not many helper agents
- A prompt injection detector does not work in agent tests
- CarryoverBench shows that a planted attack fires again in 5 rounds
- Mercor says the average pay of its AI experts is $110 an hour
- Three US agencies release ten practices for AI agent incidents
- One prompt injection makes an AI agent send 51 times more calls
- Thinking cuts injection risk in Qwen3 but makes it larger in 2 models
- RedDarwin attack tool gets 100% success on GPT-5.6-Sol
- INFUSE tests 19 language models on 56 prompt injection attacks
- MIRAGE puts image attacks in ad slots to control web agents
- Prompt-injection gates sent more than 91.8% of inputs to a reviewer
- HiddenLayer says the Jev model is open to attacks that LLMs stop
- OWASP moves excessive agency from sixth to third in 2026
- A new test set has 38,675 page pairs for prompt injection
- The CLIOPATRA attack gets private medical data from Clio
- Participants in a public challenge wrote 208,095 attack prompts