Topic 4 of 5 · 5 min read
Automated red-teaming with garak, PyRIT and promptfoo
Goal: Pick and configure an automated red-teaming tool for an app and interpret its results without over-trusting them.
Automated red-teaming tools generate and run many attacks for you, but a clean report only means "these probes did not work", not "this app is safe". Use them for breadth and regression, and keep humans for creative, app-specific attacks.
Check yourself · 1 of 3
A red-teaming scan finishes with zero findings. What does that mean?
Why it matters
Writing hundreds of attacks by hand is slow. Three open tools do much of it: garak (NVIDIA) is a scanner with many probes and detectors, PyRIT (Microsoft) orchestrates multi-turn attacks and scoring in Python, and promptfoo generates attacks from your app's description and runs them from a config file, with a report you can add to CI.
How to choose
- Quick broad scan of a model or endpoint: garak. You point it at a target, pick probe families, and read hit rates per probe.
- Multi-turn and custom attack strategies in code: PyRIT. You compose an attacker model, a target and a scorer.
- Your own app, in CI, with your own goals: promptfoo. You describe the purpose, pick plugins (what to test) and strategies (how to disguise it), and it produces test cases and a pass/fail report.
How to configure
- Describe the target honestly: its purpose, its tools, what data it holds.
- Choose attack categories that match your threat list, not "all".
- Point the tool at the real endpoint with the real system prompt and tools, not a bare model.
- Set repeat counts so you get a rate.
- Review the failures by hand and keep good ones as saved cases.
targets:
- id: https
config:
url: https://staging.example.test/chat
redteam:
purpose: "Refund assistant for an online shop"
plugins: [pii, prompt-extraction, excessive-agency]
strategies: [jailbreak, base64, multi-turn]
Reading the report
A scanner counts failures by its own detectors, and detectors are imperfect: some flag harmless text, others miss real leaks. A tool also only tries what its authors wrote or what an attacker model invented. It does not know your business rules, such as "refunds over 200 need approval".
What goes wrong
- Treating zero findings as a pass.
- Scanning the bare model instead of the full app with its tools and data.
- Trusting detector verdicts without reading samples.
- Running once, and never again after prompt or model changes.
- Pointing it at production with real keys and customers.
Examples
Reading a scanner summary
A report shows "encoding probes: 4 of 80 hit" and "role-play probes: 0 of 60 hit". The 4 hits are the finding: open the transcripts and check each. The zero does not clear role-play; it says these 60 prompts failed. Add your own role-play cases with your product's wording.
Which tool for which job
A team ships a refund bot and wants a nightly check: promptfoo in CI with plugins for data leaks and excessive agency. A security engineer wants to study a long escalation attack in code: PyRIT. A platform team vets a newly hosted model before anyone builds on it: garak.
Key points
- garak is a broad probe scanner, PyRIT orchestrates custom multi-turn attacks in code, and promptfoo generates app-specific tests from a config for CI.
- Point a tool at the whole app with its real system prompt and tools, not at a bare model.
- A scan with no findings shows only that those probes failed, not that the app is safe.
- Detectors misjudge, so read sample failures by hand before trusting counts.
- Rerun after every prompt, model or tool change and keep useful cases as a regression suite.
Common mistakes
- Reading an empty report as proof of safety.
- Scanning the base model without the app's system prompt, tools and data.
- Accepting the tool's pass or fail labels without opening sample transcripts.
- Running the tool once at launch and never after changes.
Check yourself · 2 of 3
You want a nightly red-team check in CI that uses your app's own purpose and tools. Which tool fits best?
Check yourself · 3 of 3
Why should you test the full app instead of just the base model?
Practice items, not counted towards your mastery.
Start here
- Lessons From Red Teaming 100 Generative AI Products (Microsoft) (opens in a new tab)PaperFree
Microsoft's own lessons on scoping, simple attacks that work, and why red teaming is never finished.
- OWASP Top 10 for LLM Applications (opens in a new tab)DocsFree
The risk list to draw attack goals and test seeds from.
- promptfoo: LLM red teaming guide (opens in a new tab)DocsFree
How to generate attacks, run them against an app and read the report, with plugins and strategies explained.
More for this topic
- garak: LLM vulnerability scanner (opens in a new tab)ToolFree
An open scanner with probes and detectors; the README shows how to run it against a model.
- PyRIT: Python Risk Identification Tool (Microsoft) (opens in a new tab)ToolFree
An open framework for orchestrating multi-turn attacks and scoring responses.