PyRIT: A Framework for Security Risk Identification and Red Teaming in Generative AI System

Gary D. Lopez Munoz, Amanda J. Minnich, Roman Lutz, Richard Lundeen, Raja Sekhar Rao Dheekonda, Nina Chikanov, Bolor-Erdene Jagdagdorj, Martin Pouliot, Shiven Chawla, Whitney Maxwell, Blake Bullwinkel, Katherine Pratt, Joris de Gruyter, Charlotte Siska, Pete Bryan, Tori Westerhoff, Chang Kawaguchi, Christian Seifert, Ram Shankar Siva Kumar, Yonatan ZungerarXiv 2024 · DOI

Introduction

The rapid proliferation of Generative AI (GenAI) has introduced a vast array of security risks, ranging from the generation of hate speech and biased content to providing instructions for illicit activities. Traditional security red teaming, which often relies on manual and static testing, struggles to keep pace with the probabilistic nature and multimodal capabilities of modern GenAI systems. This paper introduces PyRIT (Python Risk Identification Toolkit), an open-source, model-agnostic framework developed by Microsoft to automate and scale the red teaming process. PyRIT addresses the "tooling gap" by providing a flexible environment for identifying novel risks across text, image, and audio modalities.

Framework Architecture

PyRIT is designed with a modular, composable architecture that allows security researchers to build complex attack pipelines. The framework is organized into six primary components:

  1. Targets: Abstractions for interacting with various endpoints, including cloud APIs (e.g., OpenAI, Azure ML) and local models (e.g., ONNX).
  2. Converters: Modules that apply transformations to prompts—such as Base64 encoding, ROT13, or LLM-based rephrasing—to bypass safety filters.
  3. Datasets: A repository of static prompts and dynamic templates used to initiate adversarial probes.
  4. Scoring Engine: An automated evaluation system that utilizes "self-ask" techniques or specialized classifiers to assess the success of an attack.
  5. Memory: A persistent storage layer (using DuckDB or Azure Tables) that tracks all interactions, enabling stateful analysis of multi-turn conversations.
  6. Orchestrators: The central logic that coordinates other components to execute sophisticated strategies, such as the Adversarial Orchestrator, which employs one LLM to iteratively probe another.
PyRIT's modular architecture showing core interfaces and their respective implementations.

Experimental Evaluation

The efficacy of PyRIT was demonstrated through several case studies, most notably the red teaming of Microsoft’s Phi-3-mini model. Researchers utilized PyRIT to generate and score thousands of prompts across 15 harm categories, including cyber-attacks and hate speech. This automated approach allowed for rapid "break-fix" cycles during the model's development.

Additionally, the framework was tested against the "Gandalf" security challenge. PyRIT successfully navigated multiple levels of difficulty, using its Adversarial Orchestrator to trick the target into revealing hidden passwords through indirect prompting techniques (e.g., requesting letters separated by specific characters).

Reduction in high-risk responses for Phi-3 after PyRIT-driven red teaming and post-training.

Key Insights

  • The Power of Multi-Turn Attacks: Stateful red teaming is essential. Models that resist direct harmful requests often succumb to multi-turn strategies where an attacker builds rapport or uses iterative reasoning to bypass defenses over several exchanges.
  • Automation as a Force Multiplier: PyRIT enables researchers to scale from dozens of manual tests to thousands of automated probes, which is critical for identifying "brittle spots" in high-dimensional model behaviors.
  • Obfuscation Effectiveness: Simple converters, such as translating prompts into low-resource languages or using non-standard encodings (e.g., ROT13), remain highly effective at evading safety filters primarily trained on standard English text.

Conclusion and Future Work

PyRIT represents a significant step toward transforming AI red teaming from a manual "art" into a scalable engineering discipline. While the framework currently supports multimodal inputs, future work will focus on expanding the library of multimodal converters and integrating advanced adversarial algorithms like GCG (Greedy Coordinate Gradient). As GenAI models continue to evolve, PyRIT's modular design ensures it can adapt to new defensive architectures and emerging risk categories.

Summary updated

BibTeX
@misc{munoz2024pyrit,
  author = {Gary D. Lopez Munoz and Amanda J. Minnich and Roman Lutz and Richard Lundeen and Raja Sekhar Rao Dheekonda and Nina Chikanov and Bolor-Erdene Jagdagdorj and Martin Pouliot and Shiven Chawla and Whitney Maxwell and Blake Bullwinkel and Katherine Pratt and Joris de Gruyter and Charlotte Siska and Pete Bryan and Tori Westerhoff and Chang Kawaguchi and Christian Seifert and Ram Shankar Siva Kumar and Yonatan Zunger},
  title = {{PyRIT: A Framework for Security Risk Identification and Red Teaming in Generative AI System}},
  year = {2024},
  eprint = {2410.02828},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2410.02828},
}
Figure