Testing LLM firewalls and guardrails with garak shields detectors

Measure how often a guard, shield or LLM firewall in front of your model blocks garak's attacks, using the shields Up and Down detectors and custom block strings, and compare guarded and unguarded runs on the same probes.

On this page

How do you measure whether a garak-tested LLM firewall actually blocks attacks?

The measurement you need is how often the guard stops garak's attacks, not how well the model behaves on its own. When a guard, shield, firewall or guardrail sits in front of a model, a scan that only targets the model tells you about the model's refusals and nothing about the layer your users actually reach. garak's shields detectors are built for this case. They look for a positive or negative response from an LLM moderation system, so a scan run through the guarded endpoint can show whether the guard flagged or blocked each attempt. Teams usually need this test before they rely on a guard for a compliance control, before they change the guard's vendor or rule set, and after any upgrade to either the guard or the model behind it.

The shields detectors come in two directions. The Up detector looks for a response that indicates the moderation system raised a flag, and the Down detector looks for a response that indicates it did not. Each detector matches the guard's output against a list of strings, and those match strings can be overridden in your configuration. The result is only as reliable as those strings. If your guard returns a block message that the default strings do not recognize, the report will undercount blocks; if a generic phrase appears in a normal answer, it will overcount them. Before you trust any percentage, run a few prompts you already know the guard should block and a few it should pass, and confirm the detector labels each one correctly. Ask your guard vendor or project for the exact block and allow responses it emits so you can set the match strings to match them.

The test also has to start with a fixed definition of success. Decide in writing what counts as a block, which probes and detectors belong to the run, and whether a blocked attempt on the guard should count as a pass for the application. Then run the same probe set against the guarded endpoint and the unguarded model, using the same generator settings, so differences come from the guard. Keep both JSONL reports, since each run records every attempt and its evaluation, and compare them attempt by attempt rather than only by summary. If the guard uses a model that updates over time, record its version and date with each run, because a block rate measured in one period does not describe the next.

How garak traffic passes through the guard to the model

A garak run starts at the generator, which sends each probe prompt to the guard endpoint over HTTP from your client infrastructure. The guard either blocks the prompt and returns its refusal, or forwards it to the model, whose reply passes back through the guard before garak sees it. The shields detector then matches the response against its Up and Down strings and writes the verdict into the JSONL report. Check that the guard is in the path you intend to measure, and that the same probes run with and without it.

Probe prompts flow through the guard to the model, and the shields detector scores each reply.

Which shields configuration fits which guard

This table compares the default shields Up and Down detectors, overridden match strings for guards with custom block wording, and testing a guard alone versus the full endpoint. Read each row as a choice you make before the scan, with the typical fit and the blind spot it leaves. The main takeaway is that a guard-only run measures the filter, while an endpoint run measures what a user actually receives.

ConfigurationWhen it fitsWhat it can miss
Default Up and Down detectorsThe guard returns recognizable block or allow wording that garak's built-in match strings already coverBlock messages the defaults do not match, which can count a blocked attack as a miss
Overridden match stringsThe guard or application uses its own refusal text, such as a custom block sentence or policy codeOverly broad strings that match benign replies, or narrow strings that miss new wording after a guard update
Guard tested aloneYou want to measure the filter's own block rate on the same probe set, before or after a configuration changeApplication-side handling, such as retries, fallback models or rewritten responses that reach the user
Full endpoint testedYou need the behavior a user or downstream system sees, including the guard, the model and any post-processingWhich layer caused a pass or fail, so a result needs a separate guard-only run to attribute it
Unguarded baseline runYou need a reference rate against the same model and probes to show what the guard changesNothing about the guard itself; it only shows the model's exposure without protection
Shared detector and probe settingsGuarded and unguarded runs use the same probes, generations and detectors so the comparison is fairDrift if prompts, system messages or generator settings differ between the two runs

Setting up a guarded and unguarded comparison run

This sequence produces two garak runs against the same probes, one reaching the model directly and one passing through the guard, so the difference in results can be attributed to the guard. The comparison is only meaningful if the block strings and endpoint settings are verified before the full scans start.

  1. Install garak and confirm the Python version

    The engineer running the scan installs garak from PyPI with pip on a host running Python 3.11 or newer, which the PyPI package requires. Both runs should be launched from the same installed version, because scores can shift between releases. Record the garak version in your test notes. The step is done when the garak command runs and reports the installed version, and the same environment is reused for both scans.

  2. Define the unguarded model generator

    Create a generator configuration that reaches the model directly, using the native generator for your provider or the REST generator if the model sits behind a custom API. The REST generator needs a short YAML file describing the endpoint, its request shape and where the response text is read from. Send one benign prompt to confirm the reply is parsed correctly. The step is done when the test prompt returns readable text in the terminal output.

  3. Define the guarded endpoint generator

    Create a second generator configuration that points at the guard, shield or firewall in front of the same model, keeping the request and response mapping identical except for the URL, authentication and any routing header. Confirm with the team that owns the guard which model it forwards to and whether it returns a block message, an error code or a rewritten answer. The step is done when a benign prompt returns through the guard and an obviously unsafe prompt returns a visible refusal or block.

  4. Select identical probes and detectors for both runs

    Choose one probe selection and save it in a config file that both runs load, so probe names, generation counts and the shields detectors are identical. Keep the default of five generations per prompt unless you set it deliberately for both runs. The shields Up and Down detectors should be the ones attached to the probes you chose. The step is done when a diff of the two config files shows only the generator section changed.

  5. Verify block strings against real guard responses

    Before the full run, send a small sample of attack prompts and benign prompts through the guard and capture the exact responses. Compare them with the Up and Down match strings that garak's shields detectors use by default. Where the guard's wording differs, add custom match strings to the detector configuration and note the change. Expect to repeat this check after any guard version change. The step is done when a sample of blocked and allowed responses each matches the intended detector outcome, with the mismatches resolved.

  6. Run both scans with separate report paths

    Run the unguarded scan and the guarded scan with the same config except for the generator, writing each to its own report directory so the JSONL files and the garak.log entries do not mix. Keep the run timestamps and versions together with the outputs. Schedule them one after another if the model endpoint has rate limits. The step is done when each run finishes and produces a JSONL report that lists every attempt and its evaluation.

  7. Compare the JSONL reports side by side

    Parse both JSONL reports and line up the attempts by probe and prompt, then count how often the guarded run blocks an attempt that the unguarded run failed. Check the reverse case too, where the guard lets through an attempt the model refused, and review a sample of those by hand. Record the blocked, allowed and mismatched counts per probe family. The step is done when the comparison table shows per-probe results for both runs and every unexpected pattern has a reviewer's note.

Security and operational considerations for guard testing

Testing a guard with garak puts attack prompts, model outputs and credentials into places that often get less protection than the application itself. The cards below cover the four areas where guard test runs most often create avoidable exposure or operational cost, and what to check before the first scan.

Handle API keys in generator config

The generator configuration for a guarded endpoint usually holds an API key for the guard, the model, or both. Keep these values out of the YAML file that you commit to version control, and load them from environment variables or a secrets manager at run time. Use a key scoped to the test environment with its own spending limit, so a leaked key cannot run up charges on production accounts. Rotate it after any scan that ran on a shared host.

garak user guide

Restrict access to garak.log

The garak.log file is continued across runs and records debugging detail, so it can contain request and response content from the guard and the model. Treat it as sensitive, store it with the same access controls as the JSONL reports, and set a retention rule that matches your data policy. Confirm with your security team who may read it before you share a run directory with a vendor or a contractor.

Control access to JSONL reports

Each run writes a JSONL report of every attempt and its evaluation, which means the report holds the attack prompts, the guard's block or pass decision, and any output the model produced when the guard let a prompt through. Store reports in a location with role-based access, avoid attaching them to tickets or chat threads, and decide who may compare runs. Blocked-versus-passed results are useful evidence, but the raw text may still reveal policy weaknesses you do not want widely circulated.

Plan scans against production guards

Running garak against a production guard sends a large volume of adversarial traffic through the same path as real users, which can trigger rate limits, consume paid guard or model calls, and skew the fraud or abuse signals your team monitors. Ask the guard vendor or platform owner for written approval, agree on a time window and a request ceiling, and tag test traffic so it can be filtered from analytics. Ask for the cost model before you start, since per-call pricing decides how many probes you can afford to run.

Keep the test environment isolated

A guard test environment should not read, store or forward live user data. Use synthetic conversations and test accounts, confirm that the guard's logging and any third-party moderation service do not retain prompts from the test, and block outbound paths the test does not need. If a RAG or agent endpoint is in scope, check that its retrieval index and tools point at test data, because an injection probe that succeeds against live records is a data incident, not a finding.

Comparing guarded and unguarded runs without misreading the gap

The only fair comparison between a guarded and an unguarded run is one where the probes, generations per prompt, detectors and target model settings are identical, and only the presence of the guard changes. Pin the garak version, the probe selection, the generator configuration file and the detector list in one scan config, then run it twice: once against the model directly and once against the same model behind the firewall or guardrail. If the probe set drifts between runs, the difference in failure rates tells you about the drift, not the guard. Keep the default of 5 generations per prompt on both runs unless you change it on purpose, because garak marks a probe as FAIL when any attempt produces undesirable output, so the generation count directly moves the failure rate.

Reading the gap requires two more checks. First, a lower failure rate on the guarded run can come from blocking that also refuses legitimate requests. A guard that returns a canned refusal to everything will look excellent in a shields run, so review the attempts where the guard responded and sample the benign prompts in your own test set to measure how many legitimate answers the guard dropped. Second, confirm what the shields detectors actually matched. The Up and Down detectors look for positive or negative responses from the moderation system, and their match strings can be overridden with custom block strings. If your firewall returns a block message that does not match the default strings, the detector will miss it and the guarded run will look worse than it is. Read the JSONL report entries for a sample of blocked and passed attempts before you trust the number.

Record the garak version and the guard version with every report, including the exact release of NeMo Guardrails or any other guard, its configuration folder and the model it wraps. garak v0.17.1 was released on 16 October 2026, and report scores can shift between garak releases, so a run on a newer version cannot be compared with an older baseline without rerunning both. Store the garak.log file and the report together with these version details so that a later comparison can be reproduced. Confirm the guard's own release notes for changes to its default policies, since a guard upgrade can change the gap without any change to the model.

Questions buyers ask before testing a guard with garak

What drives the cost and effort of testing a guard with garak?

The main drivers are how many guarded and unguarded endpoints you compare, how many probe families you run, and how much of the guard's configuration has to be wired into garak before the first run. Each run calls the target model, and the guard may add its own latency and per-request charges, so the number of generations per prompt multiplies the work. garak's default is 5 generations per prompt, which you can reduce or raise in configuration. Ask any partner to split the quote into setup of the endpoint and shield detectors, the scan runs, the analysis of blocked versus passed attempts, and any retest after the guard is tuned. Those costs are one-time for setup and recur with each rescan after a guard or model change.

How long does a guarded versus unguarded comparison take to set up and review?

The duration depends on how quickly the guarded application can be reached through garak's REST generator or another supported generator, and on how much output review your team needs. garak's REST generator is configured with a short YAML file describing the endpoint, so wiring a simple chat API is usually the quick part. Time goes into confirming that the guard returns a clear positive or negative response the shields detectors can match, and into reviewing the JSONL report for each attempt. No duration is given here because it varies with the environment, so ask for a timeline in the written scope and confirm the endpoint details with your platform team first.

What must our team provide before a guard test starts?

You need to provide three things: access to the target endpoint, the guard's configuration, and sample responses that show how the guard answers when it blocks and when it passes a request. Endpoint access means a test environment that behaves like production, with credentials scoped for the scan and a way to reach it from the host running garak. Guard configuration covers the policy, rails or rules in use, plus any custom block strings your team expects, since the shields Up and Down detectors can have their match strings overridden. Sample responses let the team confirm the detector patterns match your guard's real wording before the full run. Confirm rate limits and logging retention with the platform owner as well.

Can our in-house team run a garak guard test without a partner?

Yes, a team with Python and API skills can install garak from PyPI, configure a generator for its endpoint, and run the shields detectors. garak is installed with pip and requires Python 3.11 or newer, and it is developed on Linux and macOS. The harder parts are interpreting the results and deciding what a block means for your risk, which requires someone who knows the guard's policy and the application's threat model. Check whether your team has the time to tune detector strings, rerun comparisons after each guard change, and document the evidence for security reviews. A partner is most useful for the setup and review work, not for running the tool itself.

Is garak free to use for testing guards and firewalls?

garak is licensed under Apache 2.0 and is developed in the NVIDIA GitHub organization, and the maintainers describe it as a free tool. The license covers the software itself, so the main costs are the people running the tests, the compute and model API usage for each scan, and any guard product licenses you already pay for. Review the Apache 2.0 terms with your legal team before you embed garak in an internal pipeline, and confirm the license of any guard or model you test against, because those are separate products. The official user guide is at the garak documentation site, which is the best next read for setup details.

When should we move from garak alone to a human review?

Move to human review when a block or pass result carries real consequences, such as a guard that protects customer data, regulated workflows or tool actions. garak measures how often attempts are blocked, but it cannot judge whether a blocked answer still leaked information in a partial form, or whether a pass exposed something a regulator would count as a failure. Human review is also needed when a detector matches the wrong text, when the guard changes its wording, or when the application uses tools that can act on the output. A review by a security engineer or red team should cover the guard's policy, the failing attempts in the JSONL report and the retest after fixes.

How do we know the guard test results are reliable enough to share?

Treat a single run as a snapshot, not as proof. Repeat the same probe set on the guarded and unguarded endpoints, keep the configuration identical, and record the garak version used, since scores can shift between releases. The JSONL report records every attempt and its evaluation, and the garak.log file keeps debugging detail across runs, so keep both with the test configuration. Ask whether the detector match strings were checked against sample responses before the run, because a mismatched string can inflate or hide blocks. Results are evidence for your own review; they are not an audit or certification.

Choosing a maintained guardrail when LLM Guard is in place

LLM Guard is archived and should not receive new rollouts. Its owner archived the protectai/llm-guard repository on 9 July 2026, and the README states that the project and its models on Hugging Face are no longer under active development or maintained. Teams that already run LLM Guard as a scanner in front of a model need a documented plan: keep the current deployment running only while it is replaced, record the archive status in your risk register, and do not add LLM Guard to new applications. Any shields run that depends on LLM Guard's block behavior should be re-baselined once the replacement is in place, because a guard that no longer receives fixes will drift away from new attack patterns.

The maintained option DeployOpen points most teams toward is NVIDIA NeMo Guardrails, licensed under Apache 2.0 and developed in the NVIDIA-NeMo/Guardrails repository. It provides input rails, output rails, dialog rails, retrieval rails for RAG chunks and execution rails for custom actions and tools, and it is configured through a config.yml file, optional Python actions and Colang files. Because it is a configuration-driven toolkit rather than a fixed list of scanners, the migration is not a one-to-one swap. Map each LLM Guard input and output scanner you rely on to a rail, a built-in model or a custom action, then decide which controls NeMo Guardrails should own and which stay in the application.

Confirm the fit in your own environment before you commit. Check the supported Python versions against your runtime, since NeMo Guardrails supports Python 3.10 through 3.13, and check whether your chosen rails and models meet your latency and data handling requirements. If you use Colang 1.0 configurations, plan a Colang 2.x migration using the nemoguardrails convert tool and budget for manual review of the converted files. Then rerun the same garak shields scan against the replacement, using the same Up and Down detectors and any custom block strings, so the before and after results are comparable.

How DeployOpen scopes and delivers guard testing

DeployOpen plans and runs guard testing for LLM firewalls and guardrails as a fixed-scope engagement. The work covers how garak's shields detectors are configured against your guard, how guarded and unguarded runs are compared, and what evidence the findings produce for your own review.

How we scope

  • The written scope names the guard or guardrail product, its version, and the endpoint garak will call.
  • Scope records which garak probe families run, and which Up and Down detector match strings apply to your guard's responses.
  • Scope states the paired guarded and unguarded targets, and the report format your security team expects to receive.

How we build

  • We configure the garak generator for your guarded endpoint and confirm that block responses are recognized by the shields detectors.
  • We set custom block strings where your guard returns wording the default detectors do not match, and record each override.
  • We run the same probe set against the guarded and unguarded targets so the block rates can be compared on equal terms.

How we hand over

  • You receive the JSONL reports, the run configuration files, and a written account of detector overrides and their reasons.
  • The findings document explains which attacks the guard blocked, which passed through, and where detector matching was uncertain.
  • Your engineers are walked through how to rerun the comparison after a guard rule, model, or garak version changes.

How we support

  • Ongoing support, upgrades and repeat testing are available as a retainer, covering reruns after guard configuration changes.
  • Retainers can include reviewing new garak releases for changes that affect shields detector results or report formats.
  • Support is scoped in writing, so you know which reruns, reviews and reports are included and which are quoted separately.

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.