Jailbreaks and Red Teaming

Probe your own system the way attackers and curious users will, and turn findings into tests and fixes.

Intermediate · about 4 hours · difficulty 3/5

Learn first: Prompt Injection and Defensive Design, Regression Testing and Evals in CI

A jailbreak convinces a model to ignore its safety training or your usage policy: role-play framings, "hypothetical" stories, encoding tricks, many-shot examples, or slowly escalating conversations. Model providers train against these, but your app adds its own policies (stay on topic, never give legal advice, never reveal internal pricing) that attackers can target.

Red teaming your app

  • Define what bad looks like: a written list of harms and policy violations specific to your product.
  • Manual probing: have people from outside the team try to break it. Fresh eyes find the most.
  • Automated attacks: tools such as promptfoo red teaming, garak or PyRIT generate large numbers of attack prompts and score responses.
  • Multi-turn attacks: test long conversations, not just single prompts, because many jailbreaks escalate gradually.

Hardening

  • Clear system prompt policies with examples of what to decline and how to decline helpfully.
  • Input and output classifiers for the highest-risk categories.
  • Conversation-level limits and monitoring for repeated attempts.
  • Keep a regression set of every successful attack and run it in CI.

Balance

Over-refusal is also a failure. Track false refusals on legitimate requests alongside attack success rate.

Good enough to move on

You have a written harm taxonomy for your app, a red team run with at least 100 attack prompts, a measured attack success rate, and fixes verified by re-running the suite.

Key concepts

  • Common jailbreak techniques
  • App-specific harm taxonomy
  • Manual red teaming
  • Automated attack tools
  • Multi-turn attacks
  • Over-refusal measurement

Mini project

Run an automated red team (for example promptfoo) against your chatbot with 100+ attacks across 5 categories, fix the top two weaknesses and show the before and after success rates.

Check yourself

Why should successful attacks be added to your regression suite instead of just being fixed once?

Free resources