Book a free call

AI Red Teaming: How to Attack Your Own Model First

AI red teaming means attacking your own model or agent with hostile prompts before anyone else does, so failures surface in a test run instead of in front of users.

Hertiv engineering teamReviewed by a senior engineer
7 min read
AI Red Teaming: How to Attack Your Own Model First
On this page

Short answer

AI red teaming is a structured test in which a team tries to make its own AI system fail, using hostile prompts, trick inputs and misuse cases, before the system reaches users. The point is to find the weaknesses first, fix what can be fixed, and know what is left.

What is AI red teaming?

AI red teaming is a structured test in which a team deliberately tries to make its own AI model or agent fail. The testers act as attackers: they write hostile prompts, feed in trick inputs, and try to get the system to leak data, break its own rules, or take an action it should not take.

The name comes from military exercises, where a red team plays the enemy against a defending blue team. In AI, the red team plays the hostile user, the prompt injector, and the careless operator. The goal is not to prove the system is safe. It is to find where it breaks, while the break is still cheap to fix.

Red teaming is different from ordinary testing. Ordinary tests check that the system does what it should do. Red teaming checks what it does when someone tries to make it do what it should not do. Both matter, and neither replaces the other.

What does a red team actually attack?

A red team attacks the whole system, not just the model. The model is one part; the prompts, tools, data and guardrails around it are the rest. Most real failures live in the parts around the model, not in the model itself.

Attack typeWhat it triesWhat it can expose
JailbreakPrompts that try to bypass the rulesUnsafe answers, policy overrides
Prompt injectionHostile instructions hidden in dataThe agent following attacker orders
Data leakageQuestions that probe for private dataTraining data or customer details surfacing
Tool misusePrompts that push the agent to actWrong payments, messages or deletions
Hallucination pressureQuestions with no good answerConfident false claims presented as fact
Multi-turn trapsSlow steering over many messagesGuardrails that weaken across a conversation

The list grows as systems grow. An agent that can send email, move money or change records needs far more attack types than a chatbot that only answers questions. The attack list should match what the system can actually do.

How does a red team run work?

A red team run follows a short sequence. The aim is a list of real, repeatable failures with evidence, not a pile of one-off odd answers. Each step has a clear output, so the run can be repeated after fixes.

  1. Name the target. Write down exactly what is being tested: the model, the prompts, the tools it can call, and the data it can reach.
  2. List the harms. Decide what counts as a failure before testing starts: leaking data, unsafe advice, unauthorised actions, or wrong facts presented as true.
  3. Build the attacks. Write prompts for each harm, including variations in wording, language and framing, because a model can pass one version and fail another.
  4. Run them in production conditions. Test the system as users will meet it, with the same prompts, tools and data, not a cleaned-up demo version.
  5. Record every failure. Save the exact prompt, the exact answer, and the steps to repeat it, so a fix can be checked against the same attack.
  6. Fix, then re-run. Fix the failures, then run the same attacks again. A fix that is never re-tested is a guess, not a fix.

The run ends with a report that lists what failed, what was fixed, and what is still open. That report is the evidence that testing happened, and it is what an auditor or a customer will ask for.

What should you test first?

Test the highest-risk surface first, which is usually the part of the system that touches real data or real actions. A chatbot that only answers questions is lower risk than an agent that can send messages or move money, and the test plan should reflect that.

Start with prompt injection if the system reads outside data. Any agent that reads email, documents or web pages can be fed instructions hidden in that data, and the model may follow them as if they came from the user. Test with instructions planted in documents, in tool outputs and in pasted text.

Then test data leakage, especially if the model was trained or tuned on your own data. Ask questions that would only have an answer if private data were reachable, and check whether the answer reveals it. Test tool misuse next: ask the agent to take actions it should not take, and check whether the guardrails stop it or whether a polite rewording gets past them.

Leave the exotic attacks for later. A team that has not yet tested prompt injection and data leakage gains little from testing obscure encoding tricks. Cover the common failures first, then go deeper.

For the open-source scanners that run these checks in CI, see best open-source AI red teaming tools.

Example (hypothetical): a support agent red team run

Example (hypothetical): a company runs an AI support agent that can read order records and send refund messages. The red team plans 60 attacks: 20 prompt injections hidden in order notes, 20 data-leakage probes asking for other customers' details, and 20 tool-misuse prompts asking for refunds above the limit.

The run finds 18 failures. Nine of the 20 injection prompts get the agent to follow an instruction from an order note, 5 of the 20 leakage probes return another customer's order total, and 4 of the 20 misuse prompts produce a refund above the limit. That is 18 failures out of 60 attacks, or 30 in every 100.

The team fixes the three weak spots: order notes are marked as untrusted data, order totals are checked against the logged-in customer, and refunds above the limit need a human approval step. A re-run of the same 60 attacks finds 3 failures, all in one injection pattern the team then blocks. The run took two days; a single leaked refund or customer record in production would have cost far more.

What red teaming cannot prove

Red teaming cannot prove a system is safe. It can only show that the attacks tried so far did not work. A clean report means the tested attacks failed, not that no attack exists. Anyone who treats a clean report as proof of safety is making the most common red teaming mistake of all.

It also cannot cover what was never tested. If the test list only covers text prompts, it says nothing about image inputs, voice inputs or tool outputs. If it only tests English, it says nothing about other languages. The coverage of the test list is the coverage of the result.

Finally, red teaming cannot replace fixing the underlying design. A model that is told to be careful in its system prompt but given tools with no checks will keep failing in new ways. Testing finds the failures; design fixes stop them from recurring. For the tools that automate this testing, see best AI red teaming tools for startups.

What are the common mistakes?

The most common mistakes are testing once and stopping, testing a demo instead of production, and treating a clean report as proof of safety.

  • One-off testing. A model changes, so a single clean run means little a month later. Test on a schedule, and after every change to prompts, tools or data.
  • Testing the demo. The prompts, data and tools in production are what attackers will meet. A test on a cleaned-up demo proves nothing about production.
  • No repeat evidence. A failure without the exact prompt and steps cannot be re-tested, so nobody knows whether the fix worked.
  • Testing the model only. Most failures live in the prompts, tools and data around the model, not in the model itself.
  • Stopping at the first pass. A team that finds nothing usually tested too narrowly. Widen the attack list before declaring the system clean.
  • Ignoring the fixes. A report that lists failures nobody fixes is worse than no report, because it creates the illusion that testing happened.

Red teaming works when it is repeated, recorded and acted on. A team that tests once, files the report and moves on has bought the feeling of safety without the safety. For the wider security picture, see AI security.

Key takeaways

  • AI red teaming means trying to break your own system before an attacker does.
  • Test the whole system, not just the model: prompts, tools, data and guardrails.
  • A good run ends with repeatable failures, fixes, and a re-run against the same attacks.
  • Prompt injection, data leakage and tool misuse are the first three things to test.
  • A clean report proves the tested attacks failed, not that the system is safe.

Frequently asked questions

What is AI red teaming?

AI red teaming is a structured test where a team tries to make its own AI model or agent fail, using hostile prompts and misuse cases, so weaknesses are found before users meet them.

How is red teaming different from normal testing?

Normal testing checks that a system does what it should do. Red teaming checks what it does when someone tries to make it do what it should not do, such as leaking data or taking unauthorised actions.

Who should run a red team test?

Any team shipping an AI system that reads outside data, handles private information or takes actions should run one. A chatbot that only answers questions needs less testing than an agent that can send messages or move money.

How often should you red team an AI system?

Test on a schedule and after every change to prompts, tools, data or the model itself. A single clean run means little a month later, because the system and the attacks against it both change.

What is prompt injection in AI red teaming?

Prompt injection is a hostile instruction hidden in data the system reads, such as an email or a document, which the model then follows as if it came from the user. It is one of the first attacks a red team should test.

Can red teaming prove an AI system is safe?

No. It can only show that the attacks tried so far did not work. A clean report is evidence of testing, not proof of safety, and it says nothing about attacks that were never tried.

Found this useful? Share it.
Hertiv engineering team

Written from projects we build for clients: AI and agent systems in production. Every post is reviewed by a senior engineer before publishing and updated when practice changes.

About HertivHow we work

Shipping an AI agent that can act? Talk to Hertiv.

A senior engineer replies within one business day. Or see our AI Security service.

Book a free call

Keep reading

All posts

Tell us what you want to build

A senior engineer reads every request and replies within one business day with questions, a rough range, or a call link.

  • NDA on request before any details
  • You own all code, models and IP
  • US, UK and EU time-zone overlap

Your email app should open with your message ready to send. If it does not, write to [email protected].

Prefer email? Write to [email protected]
Estimate costBook a call