Home / Insights / QA and Software Testing

QA and Software Testing

Red-Teaming LLM Applications: How to Test for Jailbreaks, Data Leaks and Harmful Output

Guardrails and security reviews tell you what you intended to block. Red-teaming tells you what actually gets through. This is how we plan, run and score red-team rounds for LLM features, and how the findings become permanent regression tests.

TopicsQA and Software TestingGenerative AI and LLMs

Key takeaways

  • Red-teaming discovers failure modes; it does not measure how often they happen. Follow every round with systematic measurement on a fixed test set.
  • Test at two layers, the model endpoint with its safety settings and the full application through its real interface, because most serious failures sit in the integration: retrieval, tools and permissions.
  • Run open-ended rounds first to find harms nobody predicted, then guided rounds against a written harms list with clear severity definitions.
  • Indirect prompt injection through documents, web pages and emails is the attack class most teams under-test, and it matters most when the model can call tools.
  • Every confirmed finding should become an automated regression case, so a model upgrade or prompt change cannot quietly reintroduce it.

Most LLM features now ship with some protection: a system prompt that sets boundaries, input and output filters, perhaps a content moderation service. What many teams lack is evidence that these protections hold up when someone actively tries to defeat them, or when a perfectly ordinary user wanders into territory the designers did not anticipate. That evidence comes from red-teaming.

This article is for CTOs, engineering leads and QA leads responsible for an LLM application in production or close to it: a customer-facing assistant, an internal knowledge tool, a document-processing pipeline or an agent that can take actions. It explains what red-teaming is and is not, how to scope and staff a round, which attack categories to cover, how to score and report findings, and how to turn the results into tests that run on every release. It assumes you already know the OWASP risk categories; if not, start with our walkthrough of the OWASP Top 10 for LLMs.

What red-teaming is, and what it is not

Red-teaming an LLM application means deliberately probing it for harmful or unintended behaviour, using both adversarial techniques and the kinds of inputs real users might plausibly send. Microsoft’s guidance on planning red-teaming for LLMs makes a distinction that is easy to miss: harmful outputs can come from benign use as well as attacks, so a red team should include ordinary users as well as security specialists.

The same guidance is clear about the limits. Red-teaming identifies harms and maps the risk surface; it is not a measure of how widespread a harm is. A tester who finds one prompt that extracts the system prompt has proved the vulnerability exists, not that it happens in a given share of conversations. That is why red-teaming sits alongside, not instead of, an evaluation suite.

ActivityQuestion it answersOutput
Red-teamingWhat can go wrong that we did not anticipate?Findings, a harms list, reproducible examples
Systematic evaluationHow often does a known failure occur, and is it improving?Metrics on a fixed test set per release
Security review and penetration testAre permissions, secrets, network and infrastructure controls sound?Vulnerability report against standard controls
Guardrail designWhat should be blocked, transformed or escalated?Policies, filters and fallback behaviour

NIST’s Generative AI Profile (NIST AI 600-1), published in July 2024, places red-teaming across several functions of its risk framework, including testing resilience against prompt injection and data poisoning, probing for leaked personal or sensitive information, and assessing bias. It also recommends that people running these exercises should not be the same people who built the system, which is a useful rule for any team.

Scoping a round and choosing the team

Decide what you are testing

An LLM application has layers, and failures appear at each one. Microsoft’s guidance recommends testing the base model with its safety system, usually through the API, and the application itself, ideally through its real user interface, before and after mitigations. In our experience the application layer is where the serious issues live, because that is where the model meets your data, your tools and your users’ permissions.

Write a one-page scope for each round covering:

  • The system under test: environment, model and version, system prompt version, retrieval sources, tools the model can call and the permissions of the identity it runs as.
  • In-scope harms: for example jailbreaks of content policy, leakage of personal data or other tenants’ data, system prompt disclosure, unauthorised tool actions, misinformation in high-stakes answers, and excessive cost or resource use.
  • Out of scope: infrastructure attacks covered by your penetration test, denial-of-service beyond agreed limits, and anything that would touch real customer data.
  • Rules of engagement: test accounts, synthetic data, time box, and who to call if a tester finds something that looks like a live incident.

Staff it with a mix of mindsets

Useful red teams combine people with security experience, domain experts who know what a harmful answer looks like in context (a clinician for a healthcare assistant, a compliance officer for a financial one) and people who were not involved in building the product. Assign people to harm areas based on skills, and rotate assignments between rounds so fresh eyes see each area.

For example, a ten-person SaaS company might run a first round with two engineers who did not build the feature, one QA engineer, one customer success manager and one external security tester, each spending a fixed number of hours over a week. The numbers are illustrative; the principle is that the builders do not mark their own homework.

Attack categories every round should cover

The OWASP Top 10 for LLM Applications (2025) is a good map of the risk categories. For test planning, we group them into seven attack families, each with typical techniques and the evidence that counts as a finding.

Attack familyTypical techniquesWhat counts as a finding
Direct jailbreaksRole-play framing, hypothetical or fictional wrappers, instructions to ignore rules, many-turn escalation, adversarial suffixesOutput that breaches your content policy or the assistant’s defined role
ObfuscationOther languages, Base64 or other encodings, emojis, split payloads that combine laterA filter that blocks the plain version but not the obfuscated one
Indirect prompt injectionInstructions hidden in documents, web pages, emails, images or tickets that the system retrievesThe model follows instructions from content rather than from the user or system
Sensitive information disclosureAsking for other users’ records, probing retrieval for documents outside the user’s permission, membership inferenceAny data the current user should not see
System prompt leakageRequests to repeat, translate or summarise instructions; formatting tricksDisclosure of instructions, especially if they contain secrets or business logic
Excessive agencyPersuading the model to call tools with altered parameters, chain actions, or skip confirmationAn action taken that the user did not intend or is not authorised to take
Harmful or misleading contentHigh-stakes questions in the product domain, leading questions, low-context prompts that invite biasConfident wrong answers, unsafe advice, biased treatment

Give indirect injection its own track

Indirect prompt injection deserves separate attention. The research paper Not what you’ve signed up for by Greshake and colleagues showed in 2023 that LLM-integrated applications blur the line between data and instructions, so text planted in content the system retrieves can steer the model, including how it calls other APIs. OWASP’s prompt injection entry lists scenarios such as a summariser that embeds a link leaking the conversation and a poisoned document in a retrieval store. If your application reads anything it did not write itself, build a set of seeded documents, pages or emails with embedded instructions and test every ingestion path.

Test the boring paths too

Not every finding is dramatic. Long conversations that drift off topic, users pasting large documents that blow token budgets, and polite requests for advice the assistant is not qualified to give are all legitimate red-team material, and they often matter more to customers than an elaborate jailbreak.

Running a round: open-ended first, then guided

Microsoft’s guidance recommends starting with open-ended testing, where testers are not steered toward particular harms, then building a harms list from what they find and using it to guide later rounds. We follow the same sequence.

  1. Brief the testers. Explain the product, the purpose of the round, access details, time commitment, how to record findings and who to contact. Include a content warning; testers will see unpleasant output.
  2. Open-ended exploration. Testers use the product as both curious users and attackers, recording anything that looks wrong.
  3. Triage and harms list. Group findings into harm categories with a definition and example for each. This list becomes the backbone of future rounds and of your evaluation suite.
  4. Guided rounds. Assign testers to specific harms and features. Retest known issues after mitigations, and add any new harm categories discovered.
  5. Repeat after significant change. A new model version, a changed system prompt, a new tool or a new data source all justify a fresh round, at least for the affected areas.

Record findings so they can be reproduced

Each finding needs a unique ID, date, tester, environment and model version, the exact input (including any seeded document), the output or a screenshot, the harm category and the tester’s view of severity. A shared spreadsheet works for small teams and lets testers learn from each other’s attempts. Because LLM output is non-deterministic, note how many attempts it took; a finding that reproduces one time in ten is still a finding.

Automated tools help, within limits

Open-source and commercial tools can generate attack variations at volume and are useful for regression and coverage. They do not replace human testers for discovering new failure modes, particularly ones that depend on understanding your domain.

Scoring findings and deciding what to fix

A red-team report full of unprioritised examples is hard to act on. Agree a severity scale before testing starts, based on impact and exploitability.

SeverityExampleDefault response
CriticalAnother tenant’s data returned; tool performs an unauthorised write or payment-related actionBlock release or disable feature; fix and retest
HighReliable jailbreak producing content that breaches policy; system prompt containing business logic disclosedFix before release; add regression case
MediumPolicy breach only with elaborate, multi-step effort; misleading answer in a low-stakes areaMitigate in a planned sprint; monitor
LowOff-brand tone; minor role driftBacklog; review prompt and examples

Fix at the right layer

Resist the urge to patch every finding by adding another sentence to the system prompt. OWASP is explicit that no foolproof prevention for prompt injection is known, so the goal is to limit impact. The most durable fixes are architectural:

  • Least privilege. Give the application its own credentials, scoped to the current user, and enforce authorisation in code rather than asking the model to respect it.
  • Human approval for high-risk actions. Anything irreversible or financially significant should require confirmation outside the model.
  • Separate untrusted content. Mark retrieved content clearly as data and keep it apart from instructions.
  • Validate outputs deterministically. Check structure, allowed values and links in code before anything is shown or executed.
  • Filter inputs and outputs as a further layer, as described in our guide to guardrails.

Report in a form leaders can use

After each round, share a short report: top issues by severity, links to raw data, what was fixed and retested, what remains open with an owner and date, and the plan for the next round.

Turning findings into a regression suite

The most valuable output of a red-team round is not the report; it is the test cases. Models are upgraded, prompts are edited and retrieval sources change, and any of these can reintroduce a failure you fixed months ago.

How to convert findings into tests

  1. Store each confirmed finding’s input, any seeded content and the expected safe behaviour (refuse, redirect, ask for confirmation, return only permitted data).
  2. Write an automated check for each case. Deterministic checks are best where possible: no forbidden data in the output, no tool call with unauthorised parameters, no system prompt fragments. Use a model-graded check only where judgement is required, and spot-check its verdicts.
  3. Generate variations of each attack (paraphrases, other languages, encodings) so the suite tests the weakness, not the exact wording.
  4. Run the suite in the pipeline on every change to model, prompt, tools or retrieval configuration, and on a schedule against production-like environments.
  5. Track pass rates per harm category over time. This is where red-teaming meets measurement: the suite turns discovered harms into metrics you can watch.

This approach fits naturally alongside the broader evaluation practice we describe in evaluating an AI chatbot before users depend on it. Our QA and testing team builds evaluation sets and review steps into the AI features we deliver, and red-team cases are simply the adversarial part of that set.

Monitor production for new patterns

Users will find things your testers did not. Log inputs and outputs with appropriate privacy controls, flag policy-filter triggers and unusual tool-call patterns, and feed confirmed incidents back into the harms list and the suite.

Costs, risks and a pre-release checklist

Where the cost lies

  • Tester time: the main cost of each round. Domain experts are often the scarcest resource.
  • Environment: a production-like environment with synthetic data, so testers can probe freely without touching real records.
  • Tooling and model usage: automated attack generation and model-graded checks consume tokens; budget for them and cap them.
  • Remediation: architectural fixes such as permission changes take longer than prompt edits but last longer too.

Risks to manage

  • Treating examples as statistics. A round with few findings does not prove the system is safe; it may mean the round was too narrow.
  • Tester well-being. Exposure to harmful content is a real cost. Brief people, let them opt out of specific harm areas and limit session length.
  • Leaking the findings. A list of working jailbreaks against your product is sensitive. Store it with access controls.
  • Vendor changes. If you use a hosted model, the provider may update it. Pin versions where possible and rerun the suite when versions change.

Pre-release checklist

  • Scope document agreed, with in-scope harms and rules of engagement.
  • At least one open-ended and one guided round completed on the release candidate.
  • Indirect injection tested on every ingestion path the application reads from.
  • Tool calls tested for unauthorised parameters and missing confirmation.
  • Cross-user and cross-tenant data access tested with realistic permission sets.
  • No open critical or high findings; mediums have owners and dates.
  • All confirmed findings added to the automated regression suite, passing in the pipeline.
  • Production monitoring and an incident route in place for new patterns.

Frequently asked questions

How is red-teaming different from a penetration test?

A penetration test checks infrastructure, authentication and application security against known vulnerability classes. Red-teaming an LLM application focuses on model behaviour: jailbreaks, prompt injection, data leakage through the model, unsafe tool use and harmful content. Most production LLM applications need both.

How often should we red-team an LLM feature?

Before first release, and again after any significant change: a new model or version, a rewritten system prompt, a new tool or a new data source. Between rounds, the automated regression suite built from earlier findings should run on every change.

Can we rely on our model provider’s safety testing?

Provider testing covers the base model, not your application. Your retrieval sources, tools, permissions and domain create risks the provider cannot see, so you still need to test the application layer yourself.

Should we use an external red team?

External testers bring fresh techniques and independence, which NIST’s generative AI profile encourages. A practical pattern is internal rounds for every significant change and an external round before major launches or when handling sensitive data.

What do we do if a tester finds a critical issue in production?

Treat it as a security incident: restrict or disable the affected capability, check logs for evidence of real exploitation, fix at the architectural layer where possible, retest and add the case to the regression suite before re-enabling.

Sources and methodology

Guidance reflects PoliteTech delivery experience. The external references below informed specific points in this article.

  1. Microsoft Learn: Planning red teaming for large language models and their applications — accessed 9 November 2026. Team composition, testing base model and application layers, open-ended then guided rounds, recording and reporting, and the point that red-teaming is not a prevalence measure.
  2. OWASP GenAI Security Project: LLM01:2025 Prompt Injection — accessed 9 November 2026. Direct and indirect injection scenarios, obfuscation techniques, mitigations including least privilege and human approval, and the 2025 Top 10 list.
  3. NIST AI 600-1: Generative Artificial Intelligence Profile (July 2024) — accessed 9 November 2026. Red-teaming actions for prompt injection, data leakage and bias, and independence of testers from developers.
  4. Greshake et al.: Not what you’ve signed up for: Compromising Real-World LLM-Integrated Applications with Indirect Prompt Injection (arXiv, 2023) — accessed 9 November 2026. Evidence that retrieved content can carry instructions that steer LLM-integrated applications and their API calls.

Has anyone tried to break your LLM feature before your users do?

We can scope and run a red-team round on your application, score the findings and turn them into a regression suite that runs on every release.