GCG adversarial suffix attacks with garak

Learn what garak's GCG, cached GCG and BEAST suffix probes test, when a GCG adversarial suffix test belongs in your scan plan, and what generating suffixes costs compared with replaying cached ones.

On this page

What GCG adversarial suffix testing checks in your system prompt

If your assistant's system prompt must hold when users append strings to their input, you need a test that appends those strings on purpose. GCG adversarial suffix testing checks whether an appended string can push the model away from the instructions it was given, such as a confidentiality rule, a role boundary or a restricted task. garak's suffix module contains GCGCached, GCG and BEAST probes designed to disrupt a system prompt by appending an adversarial suffix, so the test asks a direct question: does the model still follow its operator's instructions when the input ends with a suffix that was not written by a person?

Teams need this test when the application depends on the system prompt as a control. That includes customer-facing assistants that must stay on topic, internal tools that restrict which data or actions the model may describe, and any product where the system prompt encodes a policy the business has to defend. A standard prompt injection test may not cover this case, because suffix attacks are machine-generated strings that look like noise rather than readable instructions. Before scheduling the test, confirm with your model vendor and your own security team which system prompt rules are binding, and write them down as the pass criteria that the detectors will be judged against.

Scope the test around the model and deployment you actually run. Confirm which garak version your team has installed, since the suffix probes belong to the same release line as the rest of the probe library, and confirm that the target endpoint accepts the appended input in the form your application uses. Keep the system prompt identical across runs so that a change in results can be traced to the model, the prompt or the suffix, not to an edit made between scans. Record the garak version, the generator and the probe names with each run so the outcome can be reproduced and compared later.

Choosing between GCG, cached GCG and BEAST

This table compares garak's three suffix probes by what each needs to run, how its adversarial suffix is produced, the compute it uses, and where it fits a scan plan. Read it as a decision aid: the cost of generating suffixes depends on the target model and hardware, so confirm each probe's behavior against the garak source at probes/suffix.py before relying on it.

ProbeWhat it needsHow the suffix is producedCompute and timeWhere it fits a scan plan
GCGAccess to the target model's weights or logits, plus a GPU-equipped hostOptimized live against the target using gradient-guided token searchHighest; generation runs during the scan and scales with the target model and hardwareTargeted research on open-weight models where you can afford a live optimization run
GCG cachedAccess to a stored set of previously generated suffixesReplayed from a cache created by an earlier GCG runLow at scan time; the cost was paid once when the cache was builtRoutine regression scans that reuse suffixes across model versions or releases
BEASTAccess to the target model's logits, plus compute for a faster searchGenerated live with a beam-style search over candidate tokensLower than full GCG per suffix in many setups, but still hardware-dependent; confirm for your modelScans where a live suffix search is wanted without the full cost of GCG
Transfer fitA target that is a black box, such as a hosted APISuffixes optimized on a different model are applied to the targetCompute is spent on the source model, not the target; success depends on how closely the models matchHosted models where the target gives no logits, with results interpreted as indicative
ReproducibilityStored suffixes, probe version and generator settings recordedFixed cache gives repeatable prompts; live runs vary with sampling and model updatesCaching trades generation time for storage and version trackingCompliance evidence and comparisons over time, where the same prompts must be rerun

How a suffix probe run moves from prompt to verdict

The run starts with the system prompt and user request that the target application uses. A suffix comes either from live GCG generation, which needs GPU compute, or from a cached file, which replays without it. The appended prompt goes to the target endpoint, and the response passes to a detector that decides whether the system prompt was disrupted. Check which suffix source you used, since only the generation step draws on GPU resources.

Suffix source determines whether GPU compute is used; replay and the target call do not need it.

Setting up a garak suffix run

This sequence takes a team from a clean Python environment to a completed garak scan that checks whether appended adversarial suffixes break the system prompt of a target model. Each step ends with a file or output the team can inspect before moving on.

  1. Confirm the Python version and install garak

    The engineer creates an isolated virtual environment on a Linux or macOS host running Python 3.11 or newer, then installs garak from PyPI with pip. Garak is developed on Linux and macOS, so teams on other platforms should confirm compatibility before choosing a host. The step is done when garak --help runs and prints its command options, and the installed version matches the release the team intends to pin.

  2. Define the target through a generator

    The engineer chooses the generator that matches the system under test: a Hugging Face Hub model, an OpenAI-compatible API, or a REST endpoint described in a short YAML file that names the URL, headers and response format. For a REST endpoint, the team confirms the response is plaintext or JSON, because the REST generator depends on that shape. The step is done when a single test prompt sent through the generator returns a readable reply and the credentials are stored outside the config file in environment variables or a secrets store.

  3. Set the system prompt the target uses

    The engineer writes the exact system prompt the application uses in production, including any instructions the team wants protected, and passes it to the generator so the target behaves as it would for real users. A mismatch here makes the result meaningless, so the team should compare the prompt against the deployed configuration. The step is done when a benign request to the target shows it following the system prompt's instructions, which confirms the baseline before any suffix is added.

  4. Select the GCG, GCGCached or BEAST probe

    The engineer selects one of the suffix probes from garak's suffix module: GCG, GCGCached or BEAST. The module's source describes these probes as designed to disrupt a system prompt by appending an adversarial suffix. GCG generates suffixes against the target, GCGCached replays suffixes stored from an earlier generation run, and BEAST is the third option in the module. The team should review the probe's documentation in the garak source before running it, because generation-based probes and cached probes place different demands on the host. The step is done when the probe name appears in the run plan and the team has recorded which suffix source it uses.

  5. Run the scan and capture the output

    The engineer runs garak against the chosen generator and probe from the command line, keeping the run's command and configuration in version control so it can be repeated. Garak's default is five generations per prompt, and the team should note any change to that setting. The run is complete when the process exits without errors and the terminal shows a per-probe result. The team should keep the run identifier so the report can be matched to the configuration later.

  6. Check the JSONL report and garak.log

    The engineer opens the JSONL report written for the run and confirms it contains one record per attempt with its evaluation, which is the file any later review will depend on. The engineer then checks that garak.log exists and has been appended to with the current run's entries, because the log continues across runs. The step is done when both files are present in the expected output location and the number of attempt records matches the probe's prompt count multiplied by the generations setting.

  7. Verify the detector output matches the probe's purpose

    The engineer reads the detector results and confirms they score whether the target's reply was pulled off its system prompt, rather than scoring an unrelated behavior. Garak's default harness applies the recommended detectors for each probe, so the team should check which detector ran and read a sample of failing and passing attempts by hand. The step is done when the team has confirmed that a FAIL reflects a genuine break of the system prompt, and any detector mismatch is noted for follow-up before results are shared.

How to read a suffix failure against a system prompt

A FAIL from garak's default probewise harness means that at least one of the default 5 generations for a prompt produced output the detector classed as undesirable. For a suffix probe, that single flag does not tell you whether the system prompt broke, whether the detector misjudged the reply, or whether the model followed the appended string in a way your business already accepts. Work through those three explanations in order before anyone treats the result as a defect. Start by opening the failing attempts and reading the model's reply against the instructions in your system prompt. If the reply abandons a restriction you actually enforce, the system prompt failed. If the reply is harmless, benign formatting, or a refusal that the detector mistook for compliance, the detector is the likely cause, and you should record that as a detector issue rather than a model issue.

Keep the evidence that lets someone else repeat your reasoning. From the run's JSONL report, retain the probe and detector names, the exact suffix strings used by GCG, GCGCached or BEAST, the target model identifier and version, the generator configuration, the system prompt version, and the full text of each failing attempt with its evaluation. The garak.log file from the same run shows errors, retries and rate-limit events that can explain odd results. Store the run with its garak version, because scores can shift between releases. Record which failures you judged acceptable and why, for example a model that answers a benign question the business allows. This record is what an internal reviewer or auditor will ask for first.

Decide whether a suffix result blocks a release by agreeing the rule before the run. A reasonable starting point is that any confirmed failure where the model discloses restricted behavior, ignores a rule that your application enforces downstream, or produces content your policy forbids blocks the release until a fix or a documented risk acceptance exists. Failures that are detector noise or accepted behavior do not block, but they should be logged. Ask your security owner to sign off on the classification of each failing attempt, and set a retest requirement after the system prompt or model changes. Confirm with your own risk owner how many confirmed failures are tolerable, because garak does not supply that threshold.

What drives GPU time and cost in suffix testing

Suffix testing costs come from a few separable components: generating new suffixes, running the target model, scaling prompts and generations, replaying cached suffixes, repeating runs after changes, and engineer time. No GPU hours or durations are given here, so ask for a quote built from your own model size, hardware and prompt count.

GPU hours to generate suffixes

The GCG probe optimizes an adversarial suffix against a model, which is compute-heavy work on accelerators you own or rent. This cost is incurred when new suffixes are created, not on every scan. Ask the partner to estimate the GPU hours for your model and prompt set, and confirm which GPUs and how many are assumed in that estimate.

Target model size and hardware

Larger models need more GPU memory and longer generation times, so the same suffix search can cost very different amounts on different hardware. Check whether the target runs locally on accelerators or behind a hosted API, because hosted endpoints bill per request and may impose rate limits. Confirm the memory footprint and throughput of your target before requesting a quote.

Prompts and generations per prompt

Cost scales with the number of prompts, the number of suffixes tried, and the generations per prompt. garak's default is 5 generations per prompt, and every generation is a model call that consumes time or API spend. Agree the prompt count and generation setting in the written scope so the quote and the run plan match.

Replaying cached suffixes

The GCGCached probe replays suffixes that were generated earlier, so routine testing avoids most of the optimization cost. Replay still calls the target model for every prompt and generation, so it is cheaper than generation but not free. Ask whether your cached suffix set is stored, versioned and reused across scans.

Repeat runs after changes

A new model version or a changed system prompt can alter how suffixes behave, so previously cached suffixes may need regeneration or retesting. Each repeat run recurs cost, so plan how often scans run and which changes trigger them. Ask for a quote that separates a one-time baseline from recurring rescans.

Engineer time for setup and review

Engineers spend time configuring the target endpoint, choosing the GCG, GCGCached or BEAST probe, and interpreting the JSONL report against the system prompt's expected behavior. This labor is often the largest cost in a small engagement and recurs with every rescan. Ask the partner to state who performs setup, who reviews results and how many review cycles are included.

Which path fits your team: live generation, cached replay or a partner

This path suits a team with its own GPU capacity and the skills to run garak against its own model endpoint. The team generates adversarial suffixes with the GCG or BEAST probes during the run, so the results reflect the current model and system prompt. The inputs are access to a GPU host sized for the chosen model, a Python 3.11 or newer environment with garak installed, and a stable test endpoint with the production system prompt configured.

  • Compute ownership: Your team pays for GPU time and storage for generated suffixes, and that cost recurs with every run.
  • Setup and tuning: Your team chooses the target, sets the generation budget and checks that the detectors score the outputs the way you intend.
  • Repeatability: Live generation can produce different suffixes between runs, so record the configuration and the JSONL reports for each run.
  • Dependency upkeep: Your team tracks garak releases and reruns the baseline after upgrades.

Confirm that your GPU host, drivers and model weights are approved for the environment, and that your data handling rules allow the target system prompt to be sent to the local model.

Security and operational risks of running suffix attacks

Suffix attacks produce artifacts and traffic that carry risk of their own, separate from the findings they report. The cards below cover what gets stored, what hits the target, where the logs go, which hosts run the attacks, how cached sets age, and how findings move to a fix and retest cycle.

Cached suffixes and reports

Cached suffix sets and the JSONL reports built from them can show which appended strings moved a system prompt, which is a map of weaknesses in your application. Store them in a restricted location with the same classification as the system prompt itself, and decide before the first run who can read, copy or delete them. Check whether reports are shared with vendors, ticketing tools or contractors, and remove them on a schedule you have written down.

Production endpoints and rate limits

Suffix probes send many prompts, and a run against a production endpoint can consume quota, trigger abuse controls, or degrade service for real users. Point garak at a staging or dedicated test deployment wherever the system prompt matches production. Confirm the provider's rate limits and any terms that govern automated testing, and agree a window and a stop condition with the owner of the endpoint before the scan starts.

Logs holding user-like content

Each run writes a JSONL report and a garak.log file that is continued across runs. Suffixed prompts can contain text that resembles customer input, and the log can capture model responses that include system prompt fragments or personal data if the target has access to any. Confirm what the log level records, set retention for both files, and keep them out of general application log pipelines unless your privacy review approves that path.

Access to GPU hosts

Generating GCG suffixes needs GPU hardware, and a host that holds model weights, credentials and optimization code is a sensitive asset. Limit login to named operators, separate the scanning host from the systems that serve production traffic, and record which accounts launched each generation job. Confirm that the host image, drivers and Python environment are patched, since the machine will load and run third-party model code.

Suffix sets tied to model versions

A suffix generated against one model version may fail on a later version, and a failure on a new version tells you little about the old one. Record the exact model identifier, weights hash or provider version, and the garak version alongside each cached set. When the model or the system prompt changes, regenerate or revalidate the suffixes rather than reusing old results as current evidence.

Fix and retest cycle

A suffix that breaks the system prompt is a finding that needs an owner, a fix and a retest against the same cached set and the same model version. Track each finding in your issue system with the report reference, the change made, and the retest result. Avoid treating a clean rerun as proof of protection, because a different suffix set or model build may still succeed, so record the scope each retest actually covered.

Questions buyers ask about GCG suffix testing

What does a GCG suffix test cost?

The cost is mostly the people time and the compute needed to generate and replay suffixes, and no DeployOpen price is stated here. Cost depends on how many target models and system prompts are in scope, whether suffixes are generated live or replayed from a cache, the GPU hours available to you, and how much analysis and retesting the engagement includes. Generating new suffixes is the expensive step, while replaying cached suffixes against a model costs far less. Ask for a written, fixed scope that lists the targets, the probes (GCG, GCGCached, BEAST), the generation method, the number of generations per prompt (garak defaults to 5), and the deliverables, so the quote can be compared line by line with your own estimate.

How long does a GCG suffix run take?

Duration depends on the hardware, the number of prompts and the number of target configurations, so no fixed duration applies. Suffix generation is iterative and GPU-bound, so a run on a small accelerator takes much longer than one on a larger GPU, and a larger prompt set multiplies the work. Replaying cached suffixes is quicker because the expensive search has already been done, though each replay still makes model calls. Garak's default of 5 generations per prompt also adds calls to every run. Ask for a timeline in the written scope that states the assumed hardware and prompt count, so the schedule can be checked against your capacity.

What do we need to provide for a suffix test?

You need to provide access to the target model, the system prompt under test, GPU capacity for generation, and an endpoint that matches production as closely as possible. Model access should be a copy or endpoint you can use for the engagement, and the system prompt should be the exact text the application sends. For generation, you need accelerator capacity in your own environment or an agreed compute arrangement. A production-like endpoint matters because garak can connect to REST endpoints that return plaintext or JSON, so testing a deployed application shows behavior that a bare model may not. Confirm these inputs with your platform and security teams before work starts.

Can our in-house team run GCG suffix tests with garak?

Yes, a team with Python and machine learning operations experience can run garak, which is installed from PyPI and requires Python 3.11 or newer. Garak itself is free and Apache 2.0 licensed, so the effort lies in setup, GPU access, configuring the REST generator or model connection, reading the JSONL report, and interpreting whether a suffix that breaks the system prompt reflects a real weakness. Teams often underestimate the time needed to build a repeatable pipeline and to explain results to product owners. A partner can take on some of that work through a fixed scope, while your team keeps ownership of the runbook and the results.

Do cached GCG suffixes stay valid after a model update?

Not necessarily, because a suffix that worked against one model version may fail against another, so cached results should be treated as a starting point rather than a permanent pass or fail. Model updates, changed system prompts, new safety tuning or a different tokenizer can all change how a suffix behaves. The safe approach is to rerun cached suffixes after every model or prompt change and to record the garak version and model identifier with each report, so results can be compared over time. Garak's GCGCached probe exists to replay stored suffixes at lower cost, and that replay is the check to repeat after an update.

Does a passing garak GCG scan mean we are compliant?

No, a garak scan is testing evidence and does not amount to a compliance certification. Garak reports which attempts produced undesirable output, and it marks a probe as failed when any attempt does. That result supports a compliance assessment but does not replace one. Independent auditors and certification bodies issue audit reports and certifications, and DeployOpen prepares systems, controls and evidence for those assessments without issuing them. Ask your assessor which evidence they expect, such as scan scope, configuration, dates, and how findings were remediated and retested.

What does a suffix test actually tell us about our application?

A suffix test shows whether appended adversarial strings can push your application to ignore its system prompt or emit output it was designed to block. The result is specific to the model, prompt, decoding settings and detectors used in that run, so it describes exposure under those conditions only. A failure is a reason to review guardrails, prompt design and output handling, while a pass means the tested suffixes did not succeed in that configuration. Ask for a written scope that explains the detectors, the number of attempts and how results will be reported so the findings can be interpreted correctly.

Limits to confirm before you rely on suffix results

A suffix probe result is only as good as the match between the probe, the installed garak build, the target model and the system prompt under test. The cards below list the points to confirm before a finding about appended adversarial strings goes into a risk register or a release decision.

Probe behavior in your garak build

Confirm that the GCG, GCGCached and BEAST probes in your installed version behave as described in probes/suffix.py. garak was released as v0.17.1 on 16 October 2026, and probe logic, defaults and detectors can change between releases. Read the source for the version you run, record the exact version in your report, and treat the suffix module as the authority over any summary, including this one.

garak suffix source

Access the target model must allow

Suffix generation depends on the attack method. Confirm whether your target exposes the access that the probe needs, such as token-level gradients from an open-weights model, or whether it only returns text through an API. A target without the required access may be tested through cached suffixes or not at all, so the scope of the result must be stated accordingly.

Transfer of cached suffixes to your build

Cached suffixes were generated against a particular model and tokenizer. Before you replay them, confirm that your model build, quantization, fine-tune and serving stack match the one the suffixes were produced for. A suffix that no longer disrupts the system prompt after a model update says little about whether the current build is resistant, so retest rather than assume.

Detector judgment on your system prompt

Check how the detector decides that a system prompt was disrupted. A generic detector may flag output that looks off without showing that your instructions were overridden. For a given application, define what a violation looks like, such as the assistant dropping a scope restriction or revealing a confidential instruction, and confirm that the detector flags it on sample outputs before you trust a pass or fail.

Results across different models

A suffix that disrupts one model does not show what happens on another, and a clean result on one model does not clear the others. Treat each model and each system prompt as a separate test target, and state in the report which model, prompt and garak version produced each result before comparing findings across a fleet.

Score shifts after upgrades

Scores can move after a garak upgrade even when your target has not changed. Rerun a fixed baseline on the old and new versions, compare the JSONL reports, and document any shift before attributing it to the model. Keep the same probe selection, generation count and detector settings across the comparison so that changes come from the tool or target rather than from configuration.

How DeployOpen scopes and delivers suffix testing

DeployOpen runs garak suffix testing as a fixed-scope engagement inside your own infrastructure, with the target system prompt, suffix probes and evidence agreed in writing before work starts. Each step produces documented results your team can rerun and review, and ongoing support is available as a retainer.

How we scope

  • Written scope names the target model, the system prompt under test and the exact suffix probes to run.
  • Scope states whether suffixes are generated live with GCG or BEAST, or replayed from cached suffixes.
  • Scope records the GPU capacity, runtime window and endpoint access your team must provide before testing begins.

How we build

  • We install garak in your environment and connect the target through a generator configured for your endpoint.
  • We set generation counts, detectors and run parameters so each suffix attempt is logged and comparable.
  • We verify the harness on a small known-safe prompt set before running the full suffix probe set.

How we hand over

  • You receive the JSONL reports, the garak log, the configuration files and the list of suffixes that broke the system prompt.
  • A written findings summary explains which system prompt rules failed, how often, and the recommended fixes.
  • We walk your security and platform engineers through how to rerun the suite and read the failure rates.

How we support

  • Retesting after prompt or model changes is included in the written scope where agreed.
  • Ongoing rescans, garak upgrades and continuous testing are available as retainers.
  • Confirm with us which garak release and suffix module version your reports depend on before upgrading.

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.