The tool garak, short for Generative AI Red-teaming and Assessment Kit, is an open-source LLM vulnerability scanner that sends large sets of adversarial prompts to a language model and automatically judges whether the responses reveal a weakness. In AI security, it plays a role similar to network scanners such as Nmap: it gives teams a repeatable, automated baseline of how a model or LLM application behaves under known attack techniques.
Originally created by researcher Leon Derczynski and now maintained under NVIDIA, the project is often called NVIDIA garak and is distributed as a Python package under the Apache 2.0 license. It covers failure classes such as jailbreaks, prompt injection, training data leakage, toxic generation, malware generation and hallucinated software packages, and it can target local models, hosted APIs and custom REST endpoints.
How the scanner is structured
The scanner is built from a small set of pluggable component types. A generator wraps the target model, a probe produces attack prompts, a detector inspects each output, and a harness decides which probes run with which detectors. An optional buff transforms prompts before they are sent, for example by paraphrasing or re-encoding them, to test whether defenses survive small variations.
Because every model output is stochastic, the scanner usually requests several generations per prompt, five by default in many configurations. A detector marks each generation as a pass or a hit, and the run reports a failure rate per probe and detector pair rather than a single yes-or-no verdict.
| Component | Function | Example |
|---|---|---|
| Generator | Connects to the model under test | Hugging Face, OpenAI-compatible API, REST, Ollama |
| Probe | Creates adversarial prompts for one weakness | DAN jailbreaks, encoding attacks |
| Detector | Judges whether an output shows the failure | String match, classifier, trigger check |
| Buff | Mutates prompts before sending | Paraphrase, lowercase, translation |
| Harness | Pairs probes with detectors and runs them | Default probewise harness |
| Evaluator | Aggregates results into scores | Pass rates and reference z-scores |
Probe families and what they test
Probes are grouped into modules, each aimed at a specific class of model misbehavior. Some reuse published attack datasets, while others generate prompts dynamically, including adaptive attacks that use a second model to refine prompts against the target.
| Probe family | Weakness targeted | Typical detector |
|---|---|---|
| dan | Role-play jailbreaks that bypass refusals | Mitigation bypass check |
| encoding | Instructions hidden in Base64 or other encodings | Decoded payload match |
| promptinject | Hijacking of instructions inside user input | Rogue string match |
| latentinjection | Injection hidden in documents or retrieved text | Trigger phrase match |
| leakreplay | Reproduction of memorized training text | Continuation overlap |
| packagehallucination | Invented software package names | Lookup against package indexes |
| malwaregen | Assistance with writing malicious code | Code presence classifier |
| xss | Output that enables data exfiltration in markup | Markdown image pattern |
Package hallucination deserves attention because it links model behavior to software supply chain risk: an attacker can register a package name that models often invent and wait for developers to install it.
Running a scan and reading results
A scan is started from the command line by naming the target type, the model and the probes, for example garak --model_type huggingface --model_name gpt2 --probes encoding. Configuration files in YAML allow teams to fix parameters such as generation count, temperature and the probe list, which is essential for comparable results across releases.
Each run writes a JSONL report with every prompt and response, a hit log containing only failures, and an HTML summary. Scores can be compared with a calibration set of reference models, expressed as z-scores, which shows whether a model is unusually weak or strong on a probe relative to its peers.
| Output | Content | Main use |
|---|---|---|
| Report file | All prompts, outputs and detector scores | Audit trail and reanalysis |
| Hit log | Only the failing generations | Triage and reproduction |
| HTML summary | Pass rates per probe and detector | Reporting to stakeholders |
| Relative z-score | Position against reference models | Benchmarking model choices |
Position among AI red teaming tools
The scanner sits between manual red teaming and production guardrails. Compared with PyRIT, which is a framework for scripting custom multi-turn attack campaigns, garak emphasizes broad, ready-made coverage with minimal setup. Compared with the Adversarial Robustness Toolbox, it focuses on text-generating models rather than classical evasion and poisoning attacks on classifiers.
Teams typically use it in three places: during model selection, in continuous integration before each release of an LLM application, and after changes to system prompts, retrieval sources or safety classifiers, where regressions are common and easy to miss.
The tool is also extensible. Organizations can write custom probes and detectors in Python for threats specific to their domain, such as leakage of internal product codes, and share findings in formats compatible with the AI Vulnerability Database, which supports consistent tracking of model weaknesses across teams and vendors.
Limitations and interpretation pitfalls
A clean scan does not prove a model is secure. Probes cover known techniques, and detectors rely on string matching or classifiers that produce false positives and false negatives, so a low failure rate means only that the tested attacks mostly failed under the tested settings.
- Scanning the bare model misses risks created by tools, retrieval and agent permissions in the full application.
- Small generation counts make rare failures invisible; important probes need more samples.
- Changing temperature or system prompts between runs breaks comparability.
- Running every probe against a paid API can be slow and expensive, so scope probes to the threat model.
Stripped to the essentials
Think of garak as a safety inspector for chatbots. It asks a language model thousands of tricky questions. Some try to make it break its rules. Others try to make it leak secrets or write harmful code.
After each answer, the tool checks whether the model slipped. At the end, it produces a report card. That report shows where the model is weak, so the team can fix problems before real users or attackers find them.
Where it is applied
A software company is preparing a customer support assistant built on an open-weight model with retrieval over its help center. Before launch, the security team runs garak against the assistant’s REST endpoint with probe families for jailbreaks, prompt injection, latent injection and markdown exfiltration, requesting ten generations per prompt.
The scan shows a 31 percent failure rate on latent injection: instructions planted in a test help article make the assistant reveal its system prompt. The team adds spotlighting to retrieved text and a stricter output filter, then reruns the same configuration. The failure rate falls to under 3 percent, and the scan is added to the release pipeline so any regression blocks deployment.