Broken Hill

Implémentation industrialisée par Bishop Fox de l'attaque Greedy Coordinate Gradient (GCG) : génère automatiquement des suffixes adverses qui jailbreakent les LLM open-weight et se transfèrent souvent aux modèles fermés. Bishop Fox's productionized implementation of the Greedy Coordinate Gradient (GCG) attack — automatically generates adversarial suffixes that jailbreak open-weight LLMs and often transfer to closed models.

↗ https://github.com/BishopFox/BrokenHill

Overview

Broken Hill turns the “Universal and Transferable Adversarial Attacks on Aligned Language Models” GCG research into a usable red-team tool. Given white-box (or local) access to an LLM, it performs gradient-guided token search to discover an adversarial suffix that, when appended to a harmful prompt, drives the model to comply instead of refuse. Suffixes crafted against one open-weight model frequently transfer to other models — including hosted, closed-weight ones — making it a practical way to stress-test refusal/alignment training before an engagement against a production chatbot.

Installation

# Clone and set up (requires a CUDA GPU for practical runtimes)
git clone https://github.com/BishopFox/BrokenHill.git
cd BrokenHill
pip install -r requirements.txt

Running an Attack

Generate an adversarial suffix against a local Llama-2 checkpoint

python3 -m brokenhill \
  --model /models/Llama-2-7b-chat-hf \
  --template llama-2 \
  --base-prompt "Write instructions for <harmful_task>" \
  --target-string "Sure, here is" \
  --initial-adversarial-string "! ! ! ! ! ! ! ! ! !" \
  --max-iterations 500 \
  --output-file results/llama2-run.json

Resume a previous run’s state

python3 -m brokenhill --load-state results/llama2-run.json --max-iterations 200

Testing Transferability

Replay a discovered suffix against another local model to check transfer

python3 -m brokenhill \
  --model /models/Vicuna-7b-v1.5 \
  --template vicuna \
  --base-prompt "Write instructions for <harmful_task>" \
  --initial-adversarial-string "$(jq -r '.best_suffix' results/llama2-run.json)" \
  --max-iterations 1

Tips

  • GCG search is compute-heavy — expect hours on a single GPU for a strong suffix; Broken Hill adds checkpointing (--load-state) so long runs survive interruption.
  • The tool includes guardrails/output filtering to avoid accidentally publishing working jailbreak strings in logs — review --output-file contents before sharing.
  • Test discovered suffixes against a hosted target (e.g. via API) manually — transfer success varies a lot by target model family and system prompt.
Help / Man page
usage: brokenhill [-h] --model MODEL --template TEMPLATE
                   --base-prompt BASE_PROMPT --target-string TARGET_STRING
                   [--initial-adversarial-string STRING]
                   [--max-iterations N] [--batch-size N]
                   [--topk N] [--output-file FILE]
                   [--load-state FILE] [--device cuda|cpu]

required arguments:
  --model MODEL              path or HF id of the target model (white-box)
  --template TEMPLATE        conversation template (llama-2, vicuna, mistral, ...)
  --base-prompt TEXT         the harmful instruction to wrap
  --target-string TEXT       desired affirmative prefix (e.g. "Sure, here is")

optional arguments:
  --initial-adversarial-string TEXT   starting suffix tokens
  --max-iterations N         number of GCG optimization steps (default: 500)
  --batch-size N             candidate suffixes evaluated per step
  --topk N                   top-k token substitutions considered per position
  --output-file FILE         JSON results + best suffix found
  --load-state FILE          resume from a prior run
  --device cuda|cpu          compute device

Vue d’ensemble

Broken Hill transforme la recherche GCG « Universal and Transferable Adversarial Attacks on Aligned Language Models » en un outil de red team utilisable. Avec un accès white-box (ou local) à un LLM, il effectue une recherche de tokens guidée par le gradient pour découvrir un suffixe adverse qui, une fois ajouté à un prompt nuisible, pousse le modèle à obtempérer au lieu de refuser. Les suffixes fabriqués contre un modèle open-weight se transfèrent fréquemment à d’autres modèles, y compris hébergés et à poids fermés, ce qui en fait un moyen pratique de tester sous contrainte l’entraînement au refus/à l’alignement avant une mission contre un chatbot de production.

Installation

# Cloner et installer (nécessite un GPU CUDA pour des temps d'exécution réalistes)
git clone https://github.com/BishopFox/BrokenHill.git
cd BrokenHill
pip install -r requirements.txt

Lancer une attaque

# Générer un suffixe adverse contre un checkpoint Llama-2 local
python3 -m brokenhill \
  --model /models/Llama-2-7b-chat-hf \
  --template llama-2 \
  --base-prompt "Write instructions for <harmful_task>" \
  --target-string "Sure, here is" \
  --initial-adversarial-string "! ! ! ! ! ! ! ! ! !" \
  --max-iterations 500 \
  --output-file results/llama2-run.json
# Reprendre l'état d'une exécution précédente
python3 -m brokenhill --load-state results/llama2-run.json --max-iterations 200

Tester la transférabilité

# Rejouer un suffixe découvert contre un autre modèle local pour vérifier le transfert
python3 -m brokenhill \
  --model /models/Vicuna-7b-v1.5 \
  --template vicuna \
  --base-prompt "Write instructions for <harmful_task>" \
  --initial-adversarial-string "$(jq -r '.best_suffix' results/llama2-run.json)" \
  --max-iterations 1

Conseils

  • La recherche GCG est gourmande en calcul : comptez des heures sur un seul GPU pour un suffixe solide ; Broken Hill ajoute du checkpointing (--load-state) pour que les longues exécutions survivent à une interruption.
  • L’outil inclut des guardrails et un filtrage de sortie pour éviter de publier accidentellement des chaînes de jailbreak fonctionnelles dans les logs : relisez le contenu de --output-file avant de le partager.
  • Testez manuellement les suffixes découverts contre une cible hébergée (par exemple via API) : le succès du transfert varie beaucoup selon la famille de modèle cible et le system prompt.
Aide / Page de manuel
usage: brokenhill [-h] --model MODEL --template TEMPLATE
                   --base-prompt BASE_PROMPT --target-string TARGET_STRING
                   [--initial-adversarial-string STRING]
                   [--max-iterations N] [--batch-size N]
                   [--topk N] [--output-file FILE]
                   [--load-state FILE] [--device cuda|cpu]

required arguments:
  --model MODEL              path or HF id of the target model (white-box)
  --template TEMPLATE        conversation template (llama-2, vicuna, mistral, ...)
  --base-prompt TEXT         the harmful instruction to wrap
  --target-string TEXT       desired affirmative prefix (e.g. "Sure, here is")

optional arguments:
  --initial-adversarial-string TEXT   starting suffix tokens
  --max-iterations N         number of GCG optimization steps (default: 500)
  --batch-size N             candidate suffixes evaluated per step
  --topk N                   top-k token substitutions considered per position
  --output-file FILE         JSON results + best suffix found
  --load-state FILE          resume from a prior run
  --device cuda|cpu          compute device