← AI Security Engineer
19 min

Red Teaming & Security Testing

Plan a safe exercise, try the main attacks, record findings and turn them into regression tests.

Lesson 7 of 10
0 done
In plain English

Red teaming means attacking your own system in a safe, scoped way, using fake data and written permission. Plan attacks across instructions, hidden content, data, tools, output and cost. Record each finding with steps to reproduce, and turn every one into a permanent regression test.

Red team
People who play the attacker to find weaknesses.
Finding
One recorded weakness, with steps to reproduce it.
Regression suite
A set of tests that run on every release.
Picture it
The red team loop
1
Plan and scope
Fake data, permission
2
Attack
Try the plan
3
Record findings
Steps and severity
4
Fix and add a test
Run it every release
Then it goes back to step 1 and repeats

You find weaknesses before an attacker does by attacking your own system. This is red teaming. It is part test and part creative thinking. This lesson shows how to plan a red team exercise, which attacks to try, how to record findings and how to turn them into permanent tests.

What red teaming is

A red team plays the attacker. It tries to make the system break its rules, leak data or misuse its tools. A blue team defends. In smaller organizations the same people may play both roles at different times. The goal is to learn, not to blame.

Set the scope and rules

  • Agree what is in scope: which systems, environments and attack types.
  • Use a test environment with fake data and accounts. Never attack real customers.
  • Get written permission from the owners.
  • Agree how to report serious findings at once.
  • Set a time box, so the exercise has an end.

A plan of attacks

red-team-plan.md
AREA                 ATTACKS TO TRY
Instructions         Override, role-play, reveal the system prompt, long and confusing input
Hidden content       Instructions in documents, web pages, emails, images, tool results
Data                 Ask for other customers' data; ask for secrets; search for private terms
Tools                Wrong arguments, huge amounts, other users' ids, chained calls
Output handling      Make the output carry code, links or markup that other systems run
Safety rules         Ask for harmful or off-limits content in disguised ways
Cost and abuse       Very long prompts, loops, repeated calls, many accounts
Languages and formats  The same attack in other languages, encodings and file types

For each: goal, steps, expected safe result, actual result, severity, fix.

Use tools carefully

Open-source and commercial tools can run many known attacks against a model or an app. They save time and give coverage. They do not replace human creativity. The best findings often come from a person who understands the product and thinks of a misuse the tools never imagined.

Record findings clearly

finding.md
TITLE: Hidden text in a shared PDF makes the assistant email private notes
SEVERITY: High        STATUS: Open        OWNER: {{name}}

WHAT HAPPENED (plain words)
A PDF with white text told the assistant to send the user's last five notes to an outside
address. The assistant did it without asking.

HOW TO REPRODUCE
1. Upload the test PDF named {{file}}  2. Ask: "Summarize my files"  3. Watch the tool log

WHY IT MATTERS
A stranger could steal private notes by sharing a file.

FIX
Treat file text as data only; block outbound email without approval; add this PDF to the test set.

RETEST: {{date}}    RESULT: {{...}}

Rate severity

  • Critical: leaks other customers' data or lets an attacker act with high power.
  • High: leaks data about one user, or lets an attacker misuse a tool.
  • Medium: breaks a safety rule without a direct path to harm.
  • Low: unusual behavior with little impact.

Turn findings into tests

A fix without a test will break again. For every finding, add the attack as a permanent test. Run the attack set on every release. Over time you build a regression suite of real attacks. New models and new prompts must pass it before shipping.

Report with care

Write for two readers. Leaders need the risk and the cost of the fix. Engineers need the steps to reproduce. Report problems without blame, and share lessons across teams.

⚠Never run attacks against production systems or real users unless you have written approval and a clear plan. Accidental harm helps nobody.
Key takeaways
  • ✓Red teaming means attacking your own system in a safe, scoped way to learn where it breaks.
  • ✓Plan attacks across instructions, hidden content, data, tools, output handling, safety rules, cost and languages.
  • ✓Record each finding with steps to reproduce, severity and a fix, and rate severity by impact.
  • ✓Turn every finding into a permanent regression test, and report without blame.
Hands-on exercise

Run a mini red team

  1. Choose a small AI app you can safely test.
  2. Try at least eight attacks from the plan. Record each result.
  3. Write one full finding using the template, including how to reproduce it.
  4. Write the regression test for it in plain words, and what result counts as a pass.
Check yourself
Q1Why use a test environment with fake data?show answer

Attacks can cause real harm. Fake data and accounts let you learn without hurting customers.

Q2Why can't tools replace human red teamers?show answer

Tools run known attacks. People who know the product imagine misuses the tools never tried.

Q3Why turn each finding into a test?show answer

A fix without a test can break again. A permanent test checks it on every release.

← Supply Chain & Model RisksGuardrails, Monitoring & Detection →
0 / 10 finished0%