All projects

Case study / LLM security research

BadTokenHYDRA

An automated red-teaming framework that runs garak, PyRIT, and a browser module as one reproducible campaign.

Role
Undergraduate researcher
Status
In active development
Group
Machine Psychology Group, Cyberpunk Division, UMass Boston
Advisor
Daniel Haehn, PhD
Started
July 2026
Stack
Python, garak, PyRIT, vLLM, PyTorch, Slurm

Signals moving through a network; violet marks adversarial input

Overview

The problem

Red-team tools for language models each come with their own configuration, prompts, scoring, and output format. A garak run and a PyRIT campaign against the same model produce results you can't line up, and re-running either one later rarely reproduces the original conditions.

That's a problem for research, where the whole point is a fair before-and-after comparison. BadToken's goal is to put the tools behind one interface and one evidence format so an adversarial evaluation can be repeated and compared rather than reconstructed from scratch.

The research question

When a model refuses a harmful request, is the refusal doing the work, or is the model simply unable to do the task? Separating "won't" from "can't" changes how you read every attack-success number.

Architecture

One engine, many heads

BadToken HYDRA architecture The HYDRA engine schedules attacks through three modules (garak, PyRIT and WebRedTeam, with X-Ray planned) against locally served models and LLM-backed web apps. Every module writes into one shared evidence record that produces a single findings report. engine HYDRA Scheduler module, attack, target Evidence format one record per finding attack modules garakProbe library (NVIDIA) PyRITMulti-turn orchestration (Microsoft) WebRedTeamBrowser-based web testing X-RayPlanned module targets Locally served LLMs vLLM on A100 nodes, Slurm LLM-backed web apps Lab-hosted test instances Shared evidence record every module writes here, so one campaign produces one comparable findings report

Step 1

Schedule

A campaign starts in the engine. The scheduler decides which module runs which attack against which target, using the same probe, generation, and seed settings every time it's re-run.

Step 2

Attack

Modules do the work they're best at: garak runs its probe library, PyRIT orchestrates multi-turn attacks, and WebRedTeam drives a real browser against LLM-backed web apps. X-Ray is parked as a future module.

Step 3

Collect evidence

Each module writes its results into one shared evidence format, so a garak hit and a PyRIT transcript can sit side by side instead of living in two incompatible logs.

Step 4

Report

One campaign produces one findings report that can be compared run to run, which is what a before-and-after experiment needs.

The library's intended interface

import BadToken

# run the standard scan suite against a served model
report = BadToken.scan(model)

# run one specific exploit against it
result = BadToken.test(model, exploit)

Implementation

Infrastructure that reproduces

Models are served with vLLM behind an OpenAI-compatible endpoint on A100 GPU nodes in the university research cluster, scheduled through Slurm and reached over an authenticated SSH tunnel. The garak and PyRIT clients run in a separate conda environment so the serving stack stays untouched.

  • vLLM 0.6.3Model serving, OpenAI-compatible API
  • torch 2.4.0Pinned for the node's CUDA 12.2 driver
  • transformers 4.46.3Pinned alongside vLLM
  • Slurm on A100Batch scheduling for long scans
  • garak + PyRITAttack modules, separate conda env
  • PythonOrchestration and analysis

I also maintain the group's cluster reference documentation: session startup, Slurm and tmux commands, storage paths, environment pins, and a model-size table.

Methodology

A before-and-after experiment

  • Baseline: a ~20,000-prompt scan across 20 garak probe families against a locally served instruction-tuned model.
  • Intervention: remove the model's refusal direction with weight editing (refusal-direction orthogonalization, after Arditi et al. 2024).
  • Re-scan: identical probe, generation, and seed parameters, with the baseline re-run the same day to rule out configuration drift.
  • Control: encoding probes, where resistance should come from capability rather than refusal.
  • Analysis: compare hit-log content, not just pass rates, and place results against a 23-model calibration baseline with Z-scores.

Outcomes

What's documented so far

  • Baseline scan complete across 20 probe families.
  • Hit-log review established as part of the method, separating real guardrail failures from short compliance markers that inflate attack-success rates.
  • Reproducible serving stack and cluster documentation in place for the group.
  • Weight-editing comparison in progress; first-author manuscript in preparation.

Lessons learned

  • A pass rate without the hit log behind it can mislead in either direction.
  • Reproducibility is mostly logistics: pinned environments, identical seeds, and same-day baselines.
  • Black-box editing tools are fine for a smoke test, but final results need a pinned, reimplemented script you can describe exactly.

Repository

Source and next steps

The BadToken repository isn't public yet; it will be linked here when it is. Next up: the web module described in the WebRedTeam case study, and indirect prompt injection carried in images rather than text, reproducing Nassi et al. (Black Hat Europe 2023).

See the research lab

Related projects