What garak security hardening for scan environments protects against
A team asked to run garak against an LLM or application has to decide two things before the first scan: where the scan runs, and what that location can reach. garak is a command-line tool installed from PyPI with pip, and the PyPI package requires Python 3.11 or newer. During a run it sends a large number of generated attacks to the target, so the machine running it becomes a client with its own credentials, network paths and files. That makes the scan host, its API keys and its output security concerns in their own right, not just a way to get test results. A host that can reach production model endpoints, internal gateways or cloud metadata services inherits all of that reach the moment someone runs a probe.
Each run writes a JSONL report of every attempt and its evaluation, plus a garak.log file that continues across runs. Those files hold the prompts garak generated, the target's responses, and any content the detectors flagged, which can include toxic, harmful or sensitive material by design. They can also capture request details that contain credentials if logging is not reviewed. The team should decide who may read these files, where they are stored, how long they are kept, and whether they leave the scan host at all. Confirm the exact fields written to your installed version's report and log before you set retention rules, because the format is tied to the release you run.
The difficulty is that the tool does not make these decisions for you. garak's defaults, such as five generations per prompt, are chosen for detection coverage, not for the host, the network path or the data handling around it. The people who choose the environment, the key storage, the target rate and the report location are the team running scans, often engineers who were asked to try the tool for one assessment. Hardening therefore has to be planned as part of the scan design, with a named owner for each decision, before the tool is pointed at anything that matters.
Which garak components hold credentials, traffic and sensitive output
A garak scan touches more than the scanner itself. The installation, generator configuration, model credentials, reports, debug logs and target endpoints each hold something worth protecting, and each can expose data or load if left uncontrolled. The cards below cover what each component holds and what a careless reader or attacker could do with it.
Pinned garak installation
The garak package is installed from PyPI and runs with the permissions of the account that starts it. Pin the exact version in a virtual environment or container image so every scan host runs the same code, and record the hash or version used for each run. An unpinned upgrade can change probes and detectors, which alters results and can introduce unreviewed code into a host that holds API keys. Confirm that installs come from an approved index and that the host cannot write to the installed package path.
- Minimum Python version
- 3.11
Generator and REST configuration files
Generator configuration files, including the YAML that describes a REST endpoint, define where garak sends prompts and how it authenticates. They often contain base URLs, header templates and sometimes literal tokens. Store them outside shared repositories, reference secrets through environment variables where the generator supports it, and review changes to them like code. A reader who copies a config file with an embedded token gains access to the model or gateway behind it.
garak user guideHosted model API keys and tokens
Generators for hosted services such as OpenAI, Hugging Face Hub, Replicate and AWS Bedrock authenticate with keys or cloud credentials that can incur charges and reach private models. Use a dedicated, scoped key per scan environment, load it at runtime from a secret store, and keep it out of shell history, logs and report metadata. Ask who can rotate the key and how quickly a leaked key can be revoked. Each probe attempt consumes paid calls, so a stolen key also carries cost exposure.
JSONL reports with sensitive output
Each run writes a JSONL file recording every attempt and its evaluation. Because probes deliberately elicit data leakage, toxic content and jailbreak responses, these files can contain harmful text, system prompt fragments and sometimes data from the target application. Treat them as sensitive output: restrict read access, set a retention period, and review them in an isolated viewer before sharing. A reader who opens a report casually may see material that violates content policies.
garak.log across runs
The garak.log debugging file continues across runs rather than starting fresh, so it accumulates prompts, responses, error messages and sometimes request details from every scan on the host. Its history can outlive the report files it accompanies. Decide where it is written, rotate or archive it on a schedule, and check whether it captures headers or tokens at the debug level you use. Anyone with access to the host can read a log that spans many engagements.
Target endpoints under test
The target is the production or staging model, gateway or application that garak probes. Each probe sends many prompts, and each prompt may be repeated multiple times, so a scan can consume quota, trigger rate limits, fill logs and inflate costs on a live system. Agree a target, a request rate and a time window with the owner, use a non-production endpoint where one exists, and confirm that the owner can stop the scan. Unplanned load on a production endpoint is a common cause of scan incidents.
- Default generations per prompt
- 5
Where to run the scan and how to hold its credentials
The table compares where a garak scan host can run and how its API keys can be supplied, with the operational cost and the later difficulties of each choice. Read each row against your own model endpoints and audit requirements, and treat the combination of host and credential method as one decision.
| Option | When it fits | Operational cost | What it makes harder later |
|---|---|---|---|
| Dedicated virtual machine | Recurring scans against production-like targets where one team owns the host and its patching | Someone must patch the OS, manage Python 3.11 or newer, and restrict outbound network access | Sharing the host with other jobs weakens isolation, and images drift unless rebuilt from a pinned configuration |
| Shared CI runner | Short, scheduled scans that gate a release and need a reproducible, logged job history | Runner images and cached files are shared, so you must confirm secrets are scoped per job and purged after the run | Runners may be reused across projects, and their logs can expose prompts or model output that you need to handle as sensitive |
| Engineer workstation | Exploratory probing while a new target is being configured | Lowest setup effort, but keys sit on a laptop that may sync, back up or leave the organization | Reproducing a scan later is hard, and revoking a key tied to one person's machine is slow and error prone |
| Container in a restricted network | Repeatable scans with a fixed image, egress limited to approved model endpoints and an audit trail | Requires image build, registry control and egress rules, which is ongoing platform work | Egress allowlists break when endpoints change, so each new target needs a network change before it can be scanned |
| Environment variables | Quick setup on an isolated host with a single operator | Keys can appear in shell history, process listings and crash dumps, so you must confirm your logging settings | Rotation means editing every job definition, and there is no per-run record of which key was used |
| Secrets manager with short-lived access | Team scans that need per-run access, rotation and an audit record of retrieval | Needs an existing secrets service, access policies and a job step that fetches credentials at run time | Adds a dependency that must be available during scans. Confirm with your own platform team that the product fits your environment |
| Mounted file with tight permissions | Single host where a secrets service is unavailable and the file can be owned by the scan user only | Operators must set owner-only read permissions and keep the file out of images and backups | Rotation requires replacing the file on every host, and file reads are not logged by default |
Build sequence for a hardened garak scan host
This sequence produces a scan host that can reach only the approved targets, holds only low-privilege keys, and writes reports to a known location. Each step ends with a check so the team can confirm the setup before any real scan runs.
Create a dedicated scan host or runner
Provision a host or CI runner used only for garak scans, with no standing access to production databases, file shares or customer data stores. Keep it in a network segment separate from production workloads. The step is closed when the team can list the host's mounted volumes and network routes and confirm none of them lead to production data stores. Ask your infrastructure team to document the expected routes so the check can be repeated later.
Install a pinned garak release
Create a virtual environment on a supported Python version (the PyPI package requires Python 3.11 or newer) and install a specific garak release with pip, for example by pinning the version in a requirements file. Choose the version from the NVIDIA/garak releases page and record it in your change log. The step is closed when
garak --versionreturns the pinned release and the environment's lock or requirements file is committed to version control.Provision a separate low-privilege key per target
Issue one API key for each model or application under test, scoped to the minimum permissions and spending limits your provider allows. Do not reuse production keys or a shared administrator key. Confirm with each provider which key scopes, rate limits and usage caps are available, since these vary by vendor. The step is closed when each key authenticates against its own target only and the team has a written inventory of key owners and expiry dates.
Place generator configuration and keys in a controlled location
Store generator configuration files and key material in a directory owned by the scan service account, outside the repository and outside shared home directories. Load keys through environment variables or a secrets manager where possible, and avoid writing them into command history or logs. The step is closed when the key file's permissions show it is readable only by the scan account (for example, a mode that excludes group and other access) and a test listing as another local user is denied.
Restrict outbound access to approved endpoints
Configure host firewall rules, proxy settings or security groups so the scan host can open connections only to the approved target endpoints and the package index needed for installs. Block everything else by default. Garak's REST generator can reach any endpoint it is configured to call, so network controls are the enforcement point, not the configuration file. The step is closed when connections to an approved endpoint succeed and connections to a blocked destination, such as a production database port or an unrelated external host, fail and appear in the firewall logs.
Set a documented output directory for reports
Choose one output directory for JSONL reports and the garak.log file, with a naming convention that includes the garak version, target and run date. Restrict write access to the scan account and decide retention and access rules before scans start, because JSONL reports can contain harmful generated text. The step is closed when a test run writes its JSONL report and garak.log to the documented path, and the team's runbook states who can read the directory and how long files are kept.
Run a small test scan and verify controls
Run a narrow probe set against one non-production or approved target, using the default generation count unless the team has documented a reason to change it. Then review the results against the controls in the previous steps: confirm the pinned version appears in the report, the scan reached only the approved endpoint, the key was used only for its target, and the output landed in the documented directory. The step is closed when every control check passes and the results are recorded as the baseline for the host.
What drives the effort of hardening a garak scan environment
This table lists the factors that change how much work it takes to harden a garak scan environment, with a way to keep each one down. Read it to see which drivers apply to your setup, then use the answers to scope the work in writing, since effort depends on your own network, identity and reporting rules.
| Driver | Why it changes effort | How to keep it down |
|---|---|---|
| Number of targets and credentials | Each model or application endpoint usually has its own API key, scope and rate limit, so every target adds secrets to store, rotate and revoke. | Limit scans to the targets that matter for the review, and use one scoped credential per target rather than a shared master key. |
| Regulated network placement | A scan host inside a regulated zone needs egress rules, change control, logging and approval before it can reach model endpoints. | Use one scan host per trust zone and reuse the network controls your security team already approves. |
| Number of people who start scans | More operators means more access paths to keys, reports and the scan host, and more review of who ran what. | Restrict scan launch to a small named group and record each run with its operator and target. |
| Report retention and readership | JSONL reports hold prompts, model outputs and evaluations, which may include harmful or sensitive text. Longer retention and wider access widen the review scope. | Set a short retention period, store reports in an access-controlled location, and delete reports that are no longer needed. |
| Scheduled versus manual runs | Scheduled scans need unattended credentials, job monitoring and alerts for failed or runaway jobs, which adds operational controls. | Start with manual runs and move to a schedule only after the target list, rate limits and credential handling are settled. |
| Reuse of existing CI and secrets tooling | If no approved secrets manager or pipeline exists for scan jobs, the team must build or review new storage and approval paths. | Reuse secrets tooling and pipelines that security has already approved. Confirm this with your security team before design starts. |
How hardening changes for cloud, restricted network and shared CI scans
A garak host in the client's own cloud account sits inside a boundary the client controls: its identity provider, network security rules, logging and key management. The main risk is that the host becomes a long-lived holder of model API keys with broad network reach. Hardening starts by treating the scan host as a workload with a narrow purpose, not a general engineering machine.
- Credentials: Prefer short-lived identities attached to the instance or workload over static keys stored in shell history or plain files. Where a provider key is unavoidable, load it from the cloud secret store at runtime and keep it out of the garak configuration committed to the repository.
- Egress: Allow outbound traffic only to the model endpoints and the report destination. Block everything else so a misconfigured probe or a prompt injection test cannot reach internal services.
- Reports: Write JSONL output and
garak.logto an encrypted volume with restricted read access, then move them to an approved bucket or store. Set a retention rule before the first run. - Failure mode to test: Confirm that a scan from this host cannot read the instance metadata of other workloads or reach internal APIs when a target is misconfigured to point at a private address.
Before go-live, confirm with your cloud team which identity, egress and logging controls already apply to the account and whether they cover the scan host by default.
In a restricted network, the scan host has no direct path to model providers. Model access goes through an approved gateway that the security team can inspect, rate limit and log. The trust boundary moves to that gateway, so the host itself should hold as little as possible and export results through a controlled path.
- Credentials: Authenticate to the gateway with a credential issued for the scan purpose, scoped to the models under test. Do not place upstream provider keys on the host, because the gateway should hold them.
- Package and model sources: Install garak and its dependencies from an internal mirror that has been reviewed, and record the version used for each scan so results can be reproduced.
- Reports: Move JSONL reports and logs out through a documented transfer process, such as a one-way export with review. Treat generated content as sensitive until someone has checked it, since probes can elicit harmful output.
- Failure mode to test: Verify that the host fails closed when the gateway is unavailable. A fallback to a direct internet route would silently bypass the approved path and its logging.
Ask the network and security teams to confirm the gateway's logging, rate limits and whether it already enforces the provider keys and model allow list you plan to use.
A shared CI runner executes scans on behalf of many pipelines, branches and possibly many teams. The trust boundary is the runner itself: other jobs, cached files and runner-level secrets may be visible to a scan. Because pipelines can be triggered by any change that reaches them, the scan configuration and its inputs must be treated as code that needs review.
- Credentials: Inject model keys through the CI secret store, scoped to protected branches or a dedicated environment. Mask them in logs, and avoid passing them as command-line arguments where other processes can read them.
- Triggers: Restrict which branches and users can start a scan against production-like endpoints. A merge request from an untrusted fork should not be able to point garak at a live target.
- Reports: Publish JSONL reports as job artifacts only to people who should see harmful generated content. Set artifact expiry and do not attach raw reports to public pages or chat channels.
- Failure mode to test: Run a job from an unprotected branch and confirm it cannot read protected secrets, and that its cache does not carry prior reports or keys into other jobs.
Check with your CI administrators whether runners are ephemeral, whether they are shared across projects and who can edit pipeline definitions.
Controls that keep harmful outputs and reports contained
garak sends prompts to live targets and writes what comes back to disk, so the scan host holds both credentials and potentially disturbing content. The controls below cover who can run scans, which keys they use, where traffic can go, and where reports may live.
Least-privilege keys per target
Issue a separate API key or token for each garak target, scoped to the models and quotas that scan needs and nothing else. Name one owner for each key who is responsible for rotation and for revoking it when a scan campaign ends. Confirm with each provider whether it supports scoped keys and per-key usage limits, since that determines how much a leaked key can do. Keep keys in a secrets manager and out of the YAML files that describe generators.
Egress allowlists for targets
Restrict outbound traffic from the scan host to the specific endpoints it is meant to test and the model APIs it depends on. A generator pointed at the wrong URL should fail at the network layer rather than send prompts to an unintended system. Review the allowlist whenever a target configuration changes, and log denied connections so misconfigurations surface during the scan instead of afterward.
Reports directory permissions and encryption
Each run writes a JSONL report of every attempt and its evaluation, so the reports directory is a complete record of prompts and model responses. Set file permissions so only the scanning service account and named reviewers can read it, and encrypt the volume or directory at rest. Confirm the scan host's disk encryption and backup policy cover this directory, because backups often copy it to places the original permissions never allowed.
garak READMEStorage rules for harmful generated content
Jailbreak and toxicity probes deliberately elicit disturbing text, and that text can be unsuitable for general file shares, ticketing systems or chat channels. Write a rule that reports containing flagged generated content are stored only in approved locations with a defined retention period. Brief reviewers before they open a report, explain what the probe category tests, and give them a clear way to escalate or pause review when content is distressing.
Redacting secrets in garak.log
garak.log is a debugging file that continues across runs, and it can capture prompts, responses and configuration details. Confirm what the log records at your chosen verbosity, and remove or mask any secret, customer identifier or personal data that might appear in a prompt or a model reply. Treat the log as sensitive by default, rotate it on a defined schedule, and keep it in the same protected location as the reports.
Access control for production scans
Limit who can start a scan against a production endpoint to a named group, and require a written approval that records the target, probe set, request volume and time window. Scans at default settings make several generations per prompt, so a production endpoint can see far more traffic than a manual test. Keep scan starts in an audited pipeline where possible, and agree in advance with the endpoint owner on rate limits and a stop condition.
- Default generations per prompt
- 5
How the scan host, keys, targets and reports sit across trust boundaries
The diagram starts with the scan host inside a restricted zone, which receives its keys from a secrets store rather than from files on the host. Garak sends probes only through an egress control that allows approved staging and production targets, and production is marked restricted so it needs explicit sign-off before any run. Results leave the host as JSONL reports and a garak.log file, both written to stores with restricted access and passed through a human review step before anyone shares content that may be harmful. Check that the egress rules match the approved target list and that report stores are not readable by the wider team.
Trust boundaries for keys, probe traffic, targets and reports in a garak scan.
How to test that the scan host fails safely
Each control in the hardening design needs a test that tries to break it, and the test result should be kept as evidence. Start by confirming the installed garak version matches the pinned release, using the version reported by the installed package and comparing it with the release you approved (the release history is on the NVIDIA/garak releases page). Then run an egress test from the scan host toward destinations outside the allowlist, such as a public address you do not expect to reach, and confirm that every attempt is refused at the firewall or proxy and logged. A passing result shows the block works from the scan host itself, not only from the documentation of the network team.
Next, prove that secrets stay out of output. Place a dummy key in a test target configuration, using a value that matches the format of a real key but is not valid, then run a scan against a harmless test target. Search every JSONL report and the garak.log file for the dummy value, including the raw request and response fields that the REST generator writes. If the value appears anywhere after redaction, the test fails. Also check file permissions: confirm that other local users cannot read the key files, the configuration directory or the report directories, by running the read attempts under a separate unprivileged account.
Finally, test the change control path. Attempt a scan against an endpoint that is marked as restricted in your target inventory, using the normal operator account, and confirm the scan is blocked until the approved change record is attached. When a test fails, stop the scan host from running new jobs, record the failing control, the expected and observed results, and the owner, fix the cause, and rerun the same test rather than a simpler one. Keep the command, the timestamp, the garak version, the test output and the retest result together so a security reviewer can follow the chain from control to evidence. Confirm with your security team which evidence format and retention period they require before the first test run.
What to monitor, back up, upgrade and document after handover
Once the scan environment is handed over, the client team owns every control that keeps garak runs contained and comparable. The cards below cover what to watch, what to back up, how to upgrade safely, how to rotate credentials and what to write down so that the next person can run and audit scans without guesswork.
Monitor request volume per target
Track how many prompts garak sends to each model or application endpoint, and how fast. Garak makes 5 generations per prompt by default, so a probe set that looked small on paper can multiply quickly. Compare each run's request count and rate against the limits agreed with the target owner, and alert when a scheduled job exceeds them or runs outside its window.
Watch egress denials and auth failures
Review firewall and proxy logs from the scan host for blocked outbound connections, and review target logs for repeated failed authentication. A denial usually means a probe or plugin reached for a host outside the allowlist, and repeated auth failures can lock out a shared service account. Treat either pattern as a stop signal and investigate before the next run.
Back up configuration and version records
Keep backups of generator YAML files, run configuration, the pinned garak version and the allowlist under change control. These files let a later run reproduce the same setup. Report backups are different: JSONL reports can contain harmful generated text and sensitive prompts, so store them encrypted with restricted access and apply the same retention rule to every copy.
garak READMERe-run the baseline after upgrades
Before moving to a newer garak release, install it in a staging copy of the host and re-run the agreed baseline scan against a non-production target. Compare probe results, detector outcomes and failure rates with the pinned run. Differences may come from the new release rather than the model, so record them and decide whether the baseline needs a new reference point before production use.
garak releasesRotate scan credentials on a schedule
Set a rotation interval for every API key and token the scan host uses, and record who owns each credential. Rotate immediately after staff changes, after a suspected exposure, or after a host rebuild. Confirm that old keys are revoked at the provider, not just removed from the host, and that the rotation does not break scheduled jobs.
Document the host, rules and operators
Write down the host build, the egress allowlist, the report retention rule and the named people authorized to run scans. Include who approves a new target and who may read reports. Review this document after each garak upgrade and each staffing change, because an outdated record is the most common reason an unauthorized scan goes unnoticed.
Questions teams ask before hardening garak scans
Can our team harden garak scan environments without outside help?
Yes, if your engineers can own isolation, secrets handling and report storage. garak is a command-line tool installed from PyPI with pip, and the PyPI package requires Python 3.11 or newer, so the host needs a supported interpreter and a pinned install. Hardening then comes down to choices your team controls: a dedicated scan host or container, egress rules that allow only the target endpoints, keys injected at runtime from a secrets manager, and a retention policy for JSONL reports. Teams without a security engineer who can review those choices, or without someone who owns the target API keys, usually get more value from a partner review. Check the work against your own network and identity standards before you rely on it.
What drives the cost and effort of hardening a garak setup?
Cost follows the number of environments, targets and approval steps, not the tool itself. garak is free to use under the Apache 2.0 license, so the spend is in engineering time, infrastructure for scan hosts, and model API or GPU time per run. The main effort drivers are how many model endpoints and applications you test, how many network zones the scan hosts must reach, how your secrets and logging platforms are set up, and how many people must sign off on the design. When you ask for a quote, request a written scope that lists each environment, each target, the controls to be built, the evidence you will receive, and which costs you pay directly to model providers.
How long does hardening garak scans take?
Duration depends on scope, and the scope is set in writing before work begins. A single scan host with one model provider and an existing secrets manager is a much smaller job than a multi-zone setup with several custom REST endpoints, a gateway, and formal security review. Timing also depends on how quickly your team confirms network paths, issues service accounts for the scan host, and approves the retention rules for harmful generated content. Most engagements are fixed-scope, so the agreed deliverables and timeline come out of the written scope rather than a standard schedule. Ask for milestones tied to environment handover and a retest, not just a completion date.
What does the work need from our team?
The work needs decisions and access from several owners at once. Expect to provide:
- Network access: outbound routes from the scan host to each target endpoint, and any proxy or allowlist rules.
- Key owners: the named people or teams who issue and rotate API keys for each model provider and application.
- Security sign-off: an approver for the isolation design, the egress rules, and how reports are stored and shared.
- Sample targets: a staging or test version of each application, plus clear rules on which production endpoints scans may touch.
Missing any of these usually delays the work more than the technical build does.
Is a shared CI runner acceptable for running garak?
Usually not for scans that hold live API keys or hit production endpoints. A shared runner may be used by many projects, may keep caches or logs that persist between jobs, and may let other pipelines read its environment. If you must use CI, run garak in an ephemeral job on a dedicated runner pool, inject keys only for that job, restrict outbound network access to the approved targets, rate-limit the run so it does not add unintended load, and delete the workspace and garak.log output when the job ends. Confirm these settings with your platform and security teams, because the answer depends on how your CI system isolates jobs in your environment.
How should we handle JSONL reports that contain harmful generated content?
Treat the reports as sensitive output from the start. A garak run writes a JSONL report of every attempt and its evaluation, and the probes are designed to elicit undesirable output, so the file can contain toxic, misleading or sensitive text. Store reports in access-controlled locations with a defined owner, restrict who can open them, and set a retention period agreed with legal and compliance. Avoid copying raw attempts into tickets, chat or dashboards. Share summaries of failing probes with remediation teams, and keep the full report in its controlled store. The garak.log file is also continued across runs, so review what it records before you archive it.
Is garak itself free to use?
Yes, the tool is free. garak is licensed under Apache 2.0 and developed in the NVIDIA GitHub organization, and its maintainers describe it as a free tool. Your costs come from elsewhere: compute for scan hosts, model API charges or GPU time for the models you test, and the engineering effort to configure targets, secure the environment and review results. Check the license terms in the repository before redistributing modified copies, and confirm the pricing of any model provider you connect, since those charges are set by the provider, not by garak.
How DeployOpen scopes, builds and hands over garak scan environments
DeployOpen approaches garak security hardening as a fixed-scope piece of work: we agree the scan hosts, targets, key handling and report controls in writing before any build starts. We then build the isolated environment inside your own infrastructure, document it, and hand it over so your team can run scans safely.
How we scope
- Map which models and endpoints garak will reach, and which must stay out of scan traffic.
- Agree the host isolation model, network egress rules and where credentials will be stored.
- Define handling rules for generated harmful content and JSONL reports, including who may read them and how long they are kept.
How we build
- Install garak from PyPI on a dedicated host, pinned to an agreed version and running on Python 3.11 or newer.
- Configure API keys through your secrets manager, with no keys written to YAML generator files or shell history.
- Set request rate limits and generation counts for each target, and test them against a staging endpoint before production use.
How we hand over
- Deliver a written runbook covering host setup, scan commands, log locations and report retention rules.
- Walk your security and platform engineers through the environment and the review steps for each run.
- Provide a verification checklist that confirms isolation, key handling and load limits still hold after changes.
How we support
- Offer ongoing support, upgrades and continuous testing as a retainer after the initial handover.
- Re-check the environment when garak releases change defaults or when new target types are added.
- Confirm with your team which support terms, response expectations and review cadence the retainer will include.

