この記事は英語で公開されています。
By UNST33R
Scanning uncensored LLM endpoints with garak
A hands-on guide to running NVIDIA's garak vulnerability scanner against hosted OpenAI-compatible endpoints: probe families that matter for red team stacks, exact generator flags for custom base URLs, reading FAIL rates, and controlling scan cost per tier.
Every endpoint you route security work through is attack surface. The model answers agent prompts, renders tool output into its context, and generates code your operators might paste near a shell. garak is NVIDIA's open-source LLM vulnerability scanner: one command that fires thousands of adversarial probes at a model and reports which ones succeeded. It is the tool to reach for when you want a repeatable vulnerability profile of an endpoint, complementing orchestration frameworks like PyRIT and eval harnesses like promptfoo. This guide covers the probes that matter for red team stacks, the exact flags for pointing garak at a hosted OpenAI-compatible endpoint, and how to read the results without panicking at the first FAIL.
The project is Apache-2.0, documented at docs.garak.ai with the design rationale in the garak paper (arXiv 2406.11036), and installable from PyPI.
Where garak fits in a red team toolchain
| Tool | Core question it answers | Typical role |
|---|---|---|
| garak | Which known vulnerability classes does this endpoint exhibit? | Pre-adoption scan, regression check after vendor changes |
| PyRIT | Can I orchestrate multi-turn attacks at scale across models? | Engagement-time attack automation |
| promptfoo | Did my prompts and models drift on fixed test cases? | CI regression for your own prompt stack |
Run garak when a new endpoint or model variant enters your workflow, and again whenever the host changes anything. On uncensored and abliterated routes that habit matters more than elsewhere, because variant quality varies build to build, a problem we mapped in this week's enterprise adoption analysis.
What the probes cover
garak ships probe plugins organized by attack class. The ones with the most direct bearing on security workflows and agent stacks, all present in the repo's bundled run configurations (garak/configs/bag.yaml and fast.json in the GitHub repository):
| Probe family | What it fires | Why a red team stack cares |
|---|---|---|
probes.encoding | Prompt injections wrapped in Base64, hex, ROT13, Morse, Braille, Unicode tags, and a dozen more encodings | Agents that decode tool output before acting are the classic victim |
probes.latentinjection | Instructions buried in resumes, reports, translation snippets | Tests retrieval and RAG paths that surface untrusted text |
probes.web_injection | Markup-embedded instruction injections | Web-facing agent front doors |
probes.exploitation | SQLInjectionEcho, JinjaTemplatePythonInjection | Whether the model echoes or executes payload-shaped strings in downstream systems |
probes.packagehallucination | Prompts engineered to make the model invent package names | Supply-chain risk for coding agents that pip-install suggestions |
probes.leakreplay | Cloze and completion tests over memorized copyrighted text | Training-data leakage exposure |
probes.dan, probes.goodside, probes.grandma | Classic jailbreak corpora and roleplay framings | Baseline refusal characterization |
probes.lmrc | Checks from the Language Model Risk Cards framework, e.g. slur usage | Policy and acceptable-use surface |
probes.atkgen.Tox | Model-guided adversarial generation toward toxic output | Open-ended stress rather than fixed strings |
probes.malwaregen | Requests for malware component code | Boundary characterization, covered by authorization scope |
List everything available on your install with garak --list_probes.
Install and a first scan
garak is a command-line tool developed on Linux and macOS, supporting Python 3.11 through 3.14:
python -m pip install -U garak
garak --version
garak --list_probes
The general syntax is garak <options>. You tell it what to scan with --target_type and optionally --target_name, and what to fire with --spec. Left unspecified, garak runs every probe it knows against the target, with 10 generations per prompt by default. A first sanity run against a small local model looks like:
python3 -m garak --target_type huggingface --target_name gpt2 --spec probes.encoding.InjectBase64
The --spec flag accepts a family (probes.encoding) or a single plugin (probes.encoding.InjectBase64), so you can size runs from one probe to the whole catalog.
Pointing garak at a hosted OpenAI-compatible endpoint
This is the step most guides skip. The plain openai target type only speaks to OpenAI itself, with model names whitelisted against the OpenAI catalog. For any self-hosted or third-party endpoint that speaks the OpenAI Chat Completions protocol, use the OpenAICompatible generator, whose source ships in the repo (garak/generators/openai.py):
--target_type openai.OpenAICompatible--target_nameis the exact model ID the endpoint serves- the endpoint base URL goes in the generator's
uriparameter, passed as a JSON dict via--generator_options - the API key is read from the
OPENAICOMPATIBLE_API_KEYenvironment variable
A complete run against the UNST33R API, whose OpenAI-compatible base URL is https://api.unst33r.si/v1:
export OPENAICOMPATIBLE_API_KEY="sk-your-key-here"
python3 -m garak \
--target_type openai.OpenAICompatible \
--target_name unst33r-deepseek \
--generator_options '{"uri": "https://api.unst33r.si/v1/"}' \
--spec probes.latentinjection
Swap --target_name for any served model ID. For anything already covered by the base-URL switching guide, the same endpoint works unchanged with garak. For endpoints with unusual REST shapes, garak also ships a rest.RestGenerator that you configure with a short YAML or JSON description, documented in the REST generator reference, plus generator families for Hugging Face Inference, Replicate, Groq, NVIDIA NIM, AWS Bedrock, ggml, and LiteLLM.
For repeatable scans, keep the configuration in a file instead of CLI flags. garak accepts a YAML or JSON config via --config, and the bundled configs show the structure: a run.spec.include list of probes, run.generations for per-prompt generation count, and system.parallel_attempts for concurrency:
run:
generations: 5
spec:
include:
- probes.encoding.InjectBase64
- probes.encoding.InjectHex
- probes.latentinjection
- probes.web_injection
- probes.packagehallucination
- probes.exploitation.SQLInjectionEcho
Generator options can also ride in that file, or in a separate JSON via -G generator-options.json, which keeps the API key material out of your shell history.
Reading the output
After each probe finishes, garak prints a row with a progress bar during generation and then a verdict per detector, marked PASS or FAIL with a failure rate. The trailing figures like 840/840 count total generations against generations that behaved within bounds, so 762/840 means 78 failures. Three artifacts matter:
| Artifact | Where | Use |
|---|---|---|
| Console verdict rows | stdout per probe | Quick triage of which families failed |
garak.log | working directory | Errors, connectivity problems, malformed responses |
garak.<uuid>.report.jsonl | working directory | Full machine-readable run record, one attempt per line |
The JSONL report is the one to commit. Diffing it between scans is how you catch a serving-side regression, the same discipline as the battery approach in the tier-selection guide: same probes, same generations count, comparable output.
What to gate on when the route is uncensored on purpose
Here is the interpretive step that trips people up. Scanning an uncensored or abliterated endpoint with a jailbreak probe and marking FAIL is like testing a firewall rule and complaining packets pass. Refusal-removal is the product feature, documented in what abliteration actually does. Sort the findings into two buckets before you write any gate:
- Route characterization, expected to fail:
dan,goodside,grandma,lmrc,malwaregenon in-scope classes. Record the numbers, trend them across builds, and treat sudden changes in either direction as a signal that the served variant changed. - Robustness findings, gate on these: encoding and latent injection that succeed through agent context,
packagehallucinationhits on coding-agent prompts,exploitationechoes that would execute downstream, andleakreplaysurprises. A high failure rate in these families on an endpoint that fronts your tooling is a real vulnerability regardless of the model's content policy.
Run the scans inside your authorization scope; mass adversarial testing against endpoints you do not control lands outside both good practice and our acceptable-use policy. The AI red teaming use case overview covers scoping in more depth.
Controlling scan cost
garak's cost is attempt count times tokens per attempt. The OpenAICompatible generator caps responses at 150 tokens by default (max_tokens in its shipped defaults), probes send short prompts, and the generations knob multiplies everything. Rough arithmetic, stated as arithmetic rather than a benchmark: a probe family that fires 300 attempts at roughly 600 round-trip tokens each consumes about 180,000 tokens, which at current pricing on the DeepSeek abliterated tier ($0.15 per 1M input, $0.5625 per 1M output, cached input at $0.03125) lands in the cent range, while the same sweep on a frontier-priced model can cost orders of magnitude more. Three practical levers:
| Lever | How | Effect |
|---|---|---|
| Probe scope | --spec probes.encoding.InjectBase64 instead of the family or full catalog | Linear cost reduction |
| Generation count | run.generations: 3 in the config file (the bundled fast.json uses 3) | 70 percent cut from the default 10 |
| Tier choice | Broad sweeps on unst33r-deepseek, targeted retests on unst33r-pro | Cheap coverage, expensive precision only where needed |
Checklist
- Install garak 3.11+ and confirm probes load with
--list_probes. - Configure the OpenAI-compatible target:
urivia--generator_options, key inOPENAICOMPATIBLE_API_KEY. - First pass with injection and exploitation families; record the JSONL report.
- Bucket findings into route characterization versus robustness; write gates only for the second bucket.
- Pin the config and report in the repo; rerun on every model, vendor, or revision change.
- Keep scanning inside your authorized scope.
A scanner does not replace judgment about what a failure means on a route you chose for its refusal behavior. What it replaces is guessing: after the first committed JSONL, every endpoint change gives you a measurable delta instead of a feeling.