Practical notes on AI/LLM red teaming
Welcome. These are practical, hands-on notes on red teaming LLMs, written from a pentester's point of view. Use the tabs above to move around: Foundation explains what you are really testing, Attacks and Methodology are the how, Bootcamp is a guided course and PortSwigger has worked labs, Scope and Attack Flow help you scope a target, and Terminology is the quick dictionary. New here? Just keep reading this tab from top to bottom. Press / any time to search everything.
Read this first. In one minute it shows you what an "AI feature" really is, the words model / chatbot / agent, and how the AI makes an answer. Once you see the picture, the other tabs make sense.
An "AI feature" is just a normal app with an AI model plugged in. You test the app the client built. The model's brain is usually the vendor's (Claude, OpenAI) and out of scope.
These three words confuse everyone. It is just a ladder - each step adds one thing.
The further right, the more it can do - and the more you can attack.
The model does not "think". It reads text and guesses the next word, again and again. The thing worth watching is not the guessing, it is who wrote the text it is guessing from. Five kinds of text end up in front of it, and only one of them was written by the people who built the app.
One picture, read left to right. Five kinds of text arrive on the left, get joined into a single string, and are handed to the model. Watch the amber document: it sits inside the green user turn, and by the time the model has it, it is gone. Every box carries the attack it turns into, and the three dashed marks are the only places a control can stand.
Every arrow carries text. The role tags survive all the way into the model, but they label turns and not authors, and all three controls are outside the box.
Look at the model box in the diagram again. The role tags went in and came out the other side, but the amber document did not: it was folded into the green user turn, and inside the model there is nothing left that says a stranger wrote it.
The roles are real. A modern API takes system, user, assistant and tool as separate fields, and they survive into the token sequence as delimiter tokens. What does not survive is anything finer than a turn.
A retrieved document has no role of its own. It is pasted inside a user turn, or inside a tool turn, so by the time the model reads it, it carries exactly the standing of the turn it was folded into. The same goes for anything a tool brought back: the wrapper and the attacker's website are one blob under one label.
And a role is a prior, not a permission. Models are trained to weight a system instruction above a user one, and most of the time that training holds. It is a tendency learned from examples, not a rule the runtime enforces, which is why a confident enough instruction sitting in a tool result can still win. Instruction and data remain the same material.
So the controls that actually exist sit before this box or after it: input filters, retrieval allowlists, output scanners, tool approval, sandboxes. The ones that try to work inside it, like instruction-hierarchy training, are priors too, and priors bend. Which is why the useful question is never "is the model safe". It is which of these arrows can an attacker write on, and what is on the other end of the box when they do.
Each layer you saw above has its own bug. This is the OWASP LLM Top 10, in plain words:
| Layer | The bug |
|---|---|
| Your input | Prompt injection - your text acts like a command. |
| The model | Jailbreak (break its safety); if fine-tuned, leak its training data. |
| Documents / RAG | Poison the documents so the model obeys them (indirect injection). |
| Tools | Make it use a tool it shouldn't, or attack the tool's input (SQLi, SSRF, run code). |
| The answer being shown | Insecure output handling - the app runs the answer as HTML/SQL, so XSS and friends. |
The same answer can be fine in one app and a disaster in another. So before you test, ask: what is this app for, and what would count as "bad" here?
| App | What "bad" looks like |
|---|---|
| Story / game generator | wants wild, creative output - almost anything goes. |
| Internal HR or support bot | must stick to the facts - making up a policy is the bug. |
| Email writer for the company | should be honest but on-brand - rude or dishonest text is the bug. |
You usually want the model's intelligence (good language and reasoning), not its knowledge - it should answer from your data and say "I don't know" otherwise.
Sources: OWASP Top 10 for LLM Apps, PortSwigger Web LLM attacks, MITRE ATLAS. Next: the Terminology tab for the words, then Methodology for the plan.