The GenAI Red Team Lab repository is designed to be extensible. We encourage you to contribute new sandboxes or exploitation examples to cover more scenarios and automated Red Teaming tools.
We follow a standard Open Source Software (OSS) contribution workflow. To contribute, please fork the original repository (GenAI Red Team Lab), create a new branch for your feature or fix, and submit a Pull Request (PR) against the original repository for review.
graph LR
A[Original Repo] -->|Fork| B[Your Fork]
B -->|Branch| C[Feature Branch]
C -->|Open| PR[Pull Request<br /> Against Original Repo]
PR -->|Merge| A
Tutorials and standalone code samples, not exploiting the sandboxes, may be added to new sudirectories in the tutorials/ directory.
Be mindful of the importance of providing a clear path for reproducing the results. Code without proper environment configuration files, model requirements, and/or instructions are not acceptable.
Contributors must weigh the value of the content for the audience against the effort of reproducing the results without proper containerization.
Exploitation examples demonstrate how to attack the sandboxes. You can create manual scripts or integrate automated scanning tools.
If you want to demonstrate a specific attack technique with a list of manually crafted prompts:
- Copy the Template: Use
exploitation/exampleas a starting point to create a new subdirectory underexploitation/(e.g.,exploitation/my_attack). - Configure the New Prompt List: Modify
config.tomlto include your list of adversarial prompts under the[attack]section.
If you want to integrate an existing security tool:
- Create a Directory: Create a new subdirectory under
exploitation/(e.g.,exploitation/my_tool). - Add the Tool: Add the tool to the directory, following the same structure as
exploitation/garak, andexploitation/promptfoo.
You can also create a more customized interaction with the sandbox by adding a new subdirectory under exploitation/ (e.g., exploitation/my_tool) and developing your own logic.
The core logic of a "sandbox" is a containerized application that exposes an API (HTTP endpoint) to a shared network. This allows exploitation tools running on the host or in other containers to interact with it.
To add a new sandbox:
-
Create a Subdirectory: Create a new subdirectory under
sandboxes/(e.g.,sandboxes/name-of-sandbox).Naming convention:
/[GenAI System Type]_[Host]_[Optional Tech Stack Details]Examples:
/llm_local,/agentic_local_mcp. -
Containerize: Add a
Containerfilethat builds your target application. Ensure it packages all necessary dependencies. -
Expose Ports: Configure the container to expose the necessary ports (e.g.,
8000for an API,7860for Gradio). -
Lifecycle Management: Add a
Makefileto simplify common operations. At a minimum, it should includeattack,stop, andallrecipes. -
Add a README: Include a
README.mdthat documents how to use the sandbox, including any dependencies and setup instructions.
Example Structure:
sandboxes/name-of-sandbox/
├── Containerfile # Definition of the app environment
├── Makefile # 'make attack', 'make stop', 'make all', etc
└── app/ # Application source code
└── main.py # Entry point exposing the API
In order to maintain uniformity accross the code base, make sure to run black and isort.
We suggest using uv to run run black and isort, in a temporary environment, via uvx:
cd [path to directory]
uvx isort --profile black . && uvx black .