garak

Scanner de vulnérabilités LLM open-source maintenu par NVIDIA. Exécute des dizaines de sondes pour l'injection de prompt, les jailbreaks, l'hallucination, la fuite de données, et plus encore contre un modèle cible. NVIDIA-maintained open-source LLM vulnerability scanner. Runs dozens of probes for prompt injection, jailbreaks, hallucination, data leakage, and more against a target model.

↗ https://github.com/NVIDIA/garak

Overview

garak (“the LLM vulnerability scanner”) is a pip-installable CLI tool that probes an LLM or LLM-backed endpoint the way a fuzzer probes a binary. It bundles dozens of probes across categories — prompt injection, jailbreaks, encoding-based bypasses, hallucination, training-data leakage, toxicity, and packagehallucination (checks whether a model recommends non-existent/typosquat package names, a real supply-chain risk). Results are scored by pluggable detectors and written to a report you can triage.

Installation

Install from PyPI

pip install garak

Verify

python -m garak --version

Basic Scan

Scan an OpenAI-compatible model with a single probe module

garak --model_type openai --model_name <model_name> --probes promptinject

Scan a local Hugging Face model

garak --model_type huggingface --model_name <model_name>

Scan every probe garak ships (slow, generates a lot of traffic)

garak --model_type openai --model_name <model_name> --probes all

Targeting a custom REST endpoint

Generic REST target — point at any HTTP-exposed model API

garak --model_type rest \
  --model_name my_target \
  --generator_option_file <rest_config.json> \
  --probes dan,encoding,malwaregen
// rest_config.json
{
  "rest": {
    "uri": "<target_url>/v1/chat",
    "headers": {"Authorization": "Bearer <api_key>"},
    "req_template_json_object": {"prompt": "$INPUT"},
    "response_json_field": "$.output"
  }
}

Selecting probes and detectors

List all available probes

garak --list_probes

Run only jailbreak (DAN-family) probes

garak --model_type openai --model_name <model_name> --probes dan

Check for package-hallucination supply-chain risk

garak --model_type openai --model_name <model_name> --probes packagehallucination

Narrow to one detector

garak --model_type openai --model_name <model_name> --probes promptinject --detectors promptinject.AttackRogueString

Tips

  • Reports land in ~/.local/share/garak/garak_runs/ (or --report_prefix) as JSONL plus an HTML summary — good for attaching to a pentest report.
  • Start with a narrow --probes set before all; a full run against a hosted API can burn significant token spend.
  • garak’s generator plugins (--model_type) cover OpenAI, Hugging Face, Cohere, ggml/llama.cpp, Replicate, and raw REST — check --list_generators for the full list before writing a custom one.
Help / Man page
garak [options]

CORE OPTIONS:
  --model_type TYPE       Generator plugin: openai, huggingface, rest, ggml,
                           replicate, cohere, nim, ...
  --model_name NAME       Model identifier for the chosen generator
  --probes LIST           Comma-separated probe modules, or 'all'
  --detectors LIST        Override auto-selected detectors
  --generator_option_file FILE   JSON config for the generator (e.g. REST headers)
  --report_prefix PREFIX  Custom path/prefix for output report

INFO:
  --list_probes            List all probe modules
  --list_detectors          List all detector modules
  --list_generators          List all generator plugins
  --version                  Show version

EXAMPLE PROBE CATEGORIES:
  dan                  Jailbreak / DAN-style prompts
  promptinject          Prompt injection attack payloads
  encoding               Encoding-based filter bypass (base64, rot13, ...)
  malwaregen              Malicious code generation
  packagehallucination    Non-existent package name recommendations
  leakreplay              Training data / verbatim leakage
  toxicity                Toxic/harmful content generation

Vue d’ensemble

garak (“le scanner de vulnérabilités LLM”) est un outil CLI installable via pip qui sonde un LLM ou un endpoint adossé à un LLM de la même manière qu’un fuzzer sonde un binaire. Il embarque des dizaines de sondes réparties en catégories : injection de prompt, jailbreaks, contournements basés sur l’encodage, hallucination, fuite de données d’entraînement, toxicité, et packagehallucination (vérifie si un modèle recommande des noms de paquets inexistants/typosquattés, un risque réel de supply-chain). Les résultats sont notés par des détecteurs interchangeables et écrits dans un rapport que l’on peut trier.

Installation

# Installer depuis PyPI
pip install garak

# Vérifier
python -m garak --version

Scan de base

# Scanner un modèle compatible OpenAI avec un seul module de sonde
garak --model_type openai --model_name <model_name> --probes promptinject

# Scanner un modèle Hugging Face local
garak --model_type huggingface --model_name <model_name>

# Scanner toutes les sondes que garak embarque (lent, génère beaucoup de trafic)
garak --model_type openai --model_name <model_name> --probes all

Cibler un endpoint REST personnalisé

# Cible REST générique : viser n'importe quelle API de modèle exposée en HTTP
garak --model_type rest \
  --model_name my_target \
  --generator_option_file <rest_config.json> \
  --probes dan,encoding,malwaregen
// rest_config.json
{
  "rest": {
    "uri": "<target_url>/v1/chat",
    "headers": {"Authorization": "Bearer <api_key>"},
    "req_template_json_object": {"prompt": "$INPUT"},
    "response_json_field": "$.output"
  }
}

Sélectionner sondes et détecteurs

# Lister toutes les sondes disponibles
garak --list_probes

# Lancer uniquement les sondes de jailbreak (famille DAN)
garak --model_type openai --model_name <model_name> --probes dan

# Vérifier le risque de supply-chain lié à l'hallucination de paquets
garak --model_type openai --model_name <model_name> --probes packagehallucination

# Restreindre à un seul détecteur
garak --model_type openai --model_name <model_name> --probes promptinject --detectors promptinject.AttackRogueString

Conseils

  • Les rapports atterrissent dans ~/.local/share/garak/garak_runs/ (ou --report_prefix) au format JSONL plus un résumé HTML : pratique à joindre à un rapport de pentest.
  • Commencer avec un jeu --probes restreint avant all ; un run complet contre une API hébergée peut coûter significativement en tokens.
  • Les plugins générateurs de garak (--model_type) couvrent OpenAI, Hugging Face, Cohere, ggml/llama.cpp, Replicate, et REST brut : vérifier --list_generators pour la liste complète avant d’en écrire un personnalisé.
Aide / Page de manuel
garak [options]

CORE OPTIONS:
  --model_type TYPE       Generator plugin: openai, huggingface, rest, ggml,
                           replicate, cohere, nim, ...
  --model_name NAME       Model identifier for the chosen generator
  --probes LIST           Comma-separated probe modules, or 'all'
  --detectors LIST        Override auto-selected detectors
  --generator_option_file FILE   JSON config for the generator (e.g. REST headers)
  --report_prefix PREFIX  Custom path/prefix for output report

INFO:
  --list_probes            List all probe modules
  --list_detectors          List all detector modules
  --list_generators          List all generator plugins
  --version                  Show version

EXAMPLE PROBE CATEGORIES:
  dan                  Jailbreak / DAN-style prompts
  promptinject          Prompt injection attack payloads
  encoding               Encoding-based filter bypass (base64, rot13, ...)
  malwaregen              Malicious code generation
  packagehallucination    Non-existent package name recommendations
  leakreplay              Training data / verbatim leakage
  toxicity                Toxic/harmful content generation