garak

Also known as: NVIDIA garak · garak LLM vulnerability scanner

On this page 7

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.

ComponentFunctionExample
GeneratorConnects to the model under testHugging Face, OpenAI-compatible API, REST, Ollama
ProbeCreates adversarial prompts for one weaknessDAN jailbreaks, encoding attacks
DetectorJudges whether an output shows the failureString match, classifier, trigger check
BuffMutates prompts before sendingParaphrase, lowercase, translation
HarnessPairs probes with detectors and runs themDefault probewise harness
EvaluatorAggregates results into scoresPass rates and reference z-scores
Core components of the scanner

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 familyWeakness targetedTypical detector
danRole-play jailbreaks that bypass refusalsMitigation bypass check
encodingInstructions hidden in Base64 or other encodingsDecoded payload match
promptinjectHijacking of instructions inside user inputRogue string match
latentinjectionInjection hidden in documents or retrieved textTrigger phrase match
leakreplayReproduction of memorized training textContinuation overlap
packagehallucinationInvented software package namesLookup against package indexes
malwaregenAssistance with writing malicious codeCode presence classifier
xssOutput that enables data exfiltration in markupMarkdown image pattern
Representative probe families

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.

OutputContentMain use
Report fileAll prompts, outputs and detector scoresAudit trail and reanalysis
Hit logOnly the failing generationsTriage and reproduction
HTML summaryPass rates per probe and detectorReporting to stakeholders
Relative z-scorePosition against reference modelsBenchmarking model choices
Reading scan output

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.