5.4.3. Version control and collaboration

2025.10.06.
AI Security Blog

Moving beyond isolated notebooks and scripts, effective AI red teaming requires a systematic way to manage code, track experiments, and collaborate securely. Version Control Systems (VCS), particularly Git, are not just developer conveniences; they are foundational pillars for reproducible, auditable, and scalable red team operations.

VCS as an Operational Log

For a red teamer, a Git repository is more than a code backup. It’s an operational diary. Every commit can represent a step in an attack chain, a new payload variant, or the discovery of a novel vulnerability. This mindset transforms how you use the tool.

Kapcsolati űrlap - EN

Do you have a question about AI Security? Reach out to us here:

A well-maintained commit history provides an immutable, timestamped record of your actions. This is invaluable for generating final reports, debriefing with the blue team, and demonstrating exactly how a vulnerability was discovered and exploited. Consider the difference in clarity between a generic commit message and one tailored for a red team operation.


# Generic, less useful commit message
git commit -m "updated script"

# A red teamer's commit message: clear, specific, and contextual
git commit -m "feat(payload): Add indirect prompt injection via PDF parsing" -m "This payload embeds invisible Unicode characters in a PDF document to bypass input filters. Effective against model v2.1. See issue #42 for details."
            

The second example provides immediate context, links to further documentation (the issue tracker), and specifies the technique and its target. This level of detail is crucial for both collaboration and post-engagement analysis.

Branching Strategies for Parallel Attacks

Branching is arguably Git’s most powerful feature for red teaming. It allows you to explore multiple attack vectors simultaneously without corrupting your primary toolkit. You can isolate experiments, develop exploits for different models, or have team members work on separate objectives in parallel.

A common and effective strategy is to maintain a stable main branch with your proven tools and create feature branches for each new engagement, technique, or target.

Git branching strategy for an AI Red Team operation. The main branch contains stable tools. A develop branch integrates new features. Specific attack vectors, like data poisoning and a new jailbreak, are developed in isolated feature branches before being merged into develop. main (Stable Toolkit) develop feature/data-poisoning-v2 feature/new-jailbreak-prompt

This approach ensures your core utilities remain functional while you experiment with potentially disruptive or unstable attack code. Once a technique is proven effective, it can be reviewed and merged into the develop branch, and eventually promoted to main.

Managing AI-Specific Assets: Models, Data, and Logs

Standard Git is optimized for text-based source code, not the large binary files common in AI projects like model weights, datasets, and extensive logs. Forcing these into a standard Git repository leads to a bloated, slow, and unmanageable history. You need specialized tools to handle these assets.

Tool Best For Mechanism Red Team Use Case
Git Source code, configuration files, small text assets Stores full file history directly in the .git directory. Tracking exploit scripts, prompt libraries, and infrastructure-as-code files.
Git LFS (Large File Storage) Medium-to-large binary files (e.g., model weights, small datasets) Replaces large files in Git with small text pointers. The actual files are stored on a separate LFS server. Versioning a custom-tuned attack model or a specific dataset used for a data poisoning attack.
DVC (Data Version Control) Very large datasets, ML pipelines, metrics Works alongside Git to version data and pipelines. Pointers are stored in Git, data in remote storage (S3, GCS, etc.). Ensuring full reproducibility of a complex attack that involves data preprocessing, model training, and evaluation.

Using the right tool for the job is critical. Your Python scripts belong in Git, the 5GB model file you’re probing belongs in Git LFS, and the 50GB log data from your fuzzing run is best managed by DVC or a similar solution.

Security and Collaboration Best Practices

A shared repository is a central point of failure if not managed correctly. Adhering to security best practices is non-negotiable.

The Indispensable .gitignore

Your .gitignore file is your first line of defense against accidentally committing sensitive information. Every AI red team repository should have a robust one from the start.


# .gitignore for an AI Red Team project

# Credentials and secrets
*.env
*.pem
*.key
credentials.json

# Python artifacts
__pycache__/
*.pyc
*.pyo
*.pyd

# Notebook checkpoints and outputs
.ipynb_checkpoints/
*.html
*.pdf

# Large data and model files (should be handled by LFS/DVC)
*.pt
*.pth
*.h5
*.onnx
/data/
/models/

# Local environment and tool configuration
.idea/
.vscode/
.venv/
venv/
            

Secrets Management

Never store API keys, passwords, or other secrets directly in your code or configuration files. Use environment variables, a dedicated secrets manager (like HashiCorp Vault or AWS Secrets Manager), or encrypted files with tools like git-crypt. Leaking credentials via a public or compromised repository is a common and devastating mistake.

Pull Requests as Peer Review

On collaborative platforms like GitHub or GitLab, use Pull Requests (or Merge Requests) as a formal peer-review mechanism. Before a new attack script or prompt library is merged into the main development branch, a teammate should review it for:

  • Effectiveness: Does the technique work as described?
  • Clarity: Is the code readable and well-documented?
  • Safety: Does it have unintended side effects? Are there safeguards to prevent it from affecting non-target systems?
  • Security: Does it introduce any new vulnerabilities or leak sensitive information?

This process improves the quality and reliability of your team’s toolkit and fosters a culture of shared knowledge and responsibility.