Beyond Suffixes: The Impact of Token Position in GCG Adversarial Attacks on Large Language ModelsBeyond Suffixes: Token Position in GCG Adversarial Attacks on Large Language Models
The authors compare GCG prefix and suffix; when Llama's suffix is transferred to Vicuna, ASR@k=2 is 73%.
Optimization is white-box GCG: token-level gradients optimize a contiguous block of adversarial tokens, as a prefix or suffix, to increase the likelihood of a specified target sentence. There is also a black-box cross-model setting: tokens optimized on one model are tested on other models. The victim system is an LLM with safety alignment. Success is determined by a GPT-4 harm score of 5.
- GCG-style jailbreaks usually append the adversarial token at the end of the prompt. The authors argue that this position is an overlooked attack axis, and that evaluation fixing a single position overestimates robustness and underestimates risk.
- Under the same GCG objective, an adversarial token of length 20 is optimized as a prefix or suffix, then evaluated at the optimized position or the other position. The data are 100 AdvBench prompts; a GPT-4 harm score of 5 counts as success, and white-box and cross-model ASR@1 and ASR@k=2 are reported.
- Which is higher under white-box varies by model. Vicuna's GCG-Prefix goes from 83% to 99% when both positions are allowed. Llama's suffix transferred to Vicuna has ASR@k=2 of 73%, an absolute increase of 49%. When transferred to Llama, it is 0% or 1%.
- The authors plan to extend the analysis to other attacks and systematically vary positions beyond prefix and suffix. The experiments cover 5 tested LLMs and 100 AdvBench prompts, comparing only GCG prefix and suffix; the paper does not report reviewer-human agreement.
- Evaluated models
- deepseek-llm-7b-chatQwen2.5-7B-InstructMistral-7B-Instruct-v0.3Llama-2-7b-chat-hfvicuna-7b-v1.5
- Benchmarks
- AdvBench
- Metrics
- ASRASR@k
Using the GCG attack as a case study, the paper investigates how the position of adversarial tokens in a prompt affects jailbreak attack success rate. The authors find that optimizing the attack as a generation prefix rather than a suffix, and changing the position of adversarial tokens during evaluation, both significantly change the attack success rate. Based on this, the authors point out blind spots in current safety evaluations and argue that adversarial robustness evaluation of large language models needs to consider the position of adversarial tokens.
Paper analysis
What problem does this paper attempt to solve?
GCG often fixes the adversarial token as a suffix; the authors state that its position itself changes the ASR.
Does the position of adversarial tokens in the prompt change the ASR of GCG jailbreaks.
- Scenario: The authors state that aligned LLMs can still be bypassed by jailbreaks, listing abuses such as writing malware, designing chemical and biological weapons, and harassment. GCG and its subsequent iterations append adversarial tokens at the end of the prompt and iteratively optimize.
- Gap: The authors state that these suffix-style attacks default to the end position, and little is known about how the position of adversarial tokens within the prompt affects jailbreaking.
- Hypothesis: The authors believe that optimizing adversarial tokens as a prefix, or moving an existing adversarial block to another position, will cause non-negligible changes in ASR. Evaluating at a single fixed position overestimates robustness and underestimates risk.
- Approach: Using GCG as a case study, compare prefix optimization with suffix optimization, and examine position changes in white-box and black-box cross-model settings.
- Threat model:
- Goal: Induce the model to generate an attacker-specified target output sequence; optimization targets the likelihood of the target tokens. The goal refers to the original harmful prompt, which is not the same object as that target sequence.
- Knowledge: Optimization is white-box, using token-level gradient approximation and greedy replacement. The black-box cross-model setting takes adversarial tokens obtained on one model and tests transfer to other models.
- Capability: Place a contiguous block of adversarial tokens, either as a prefix or suffix. The paper defines this axis as the position of the entire block, not the position of individual tokens within the block.
- Victim system: LLMs with safety alignment. Whether a jailbreak succeeds is determined by an LLM Judge.
What related research exists?
The suffix-style work discussed in the paper defaults to the end as the adversarial position; this paper treats position as an attack axis.
Following the grouping in the introduction and Section 5, the paper places existing work along three lines: alignment, suffix-style jailbreaks, and attention analysis.
Jailbreaks and GCG
- Zou et al. (2023): Proposes GCG, appending a fixed-length adversarial suffix at the end of the prompt, using greedy coordinate gradient to induce harmful outputs, and discusses transferability. This paper treats that standard form as a baseline.
- Jia et al. (2025), Mu et al. (2025): The former improves optimization-based jailbreaks; the latter proposes Mask-GCG, examining which tokens in the adversarial suffix are necessary. The introduction calls them subsequent iterations of GCG and writes that they still append tokens at the end.
- Wei et al. (2023), Chu et al. (2025): The former discusses why safety training fails; the latter provides a comprehensive evaluation taxonomy of jailbreak attacks. The paper only cites them, without numerical comparison to this work.
Safety alignment
- Ouyang et al. (2022), Rafailov et al. (2023), Qi et al. (2024b): Use human feedback, direct preference optimization, and fine-tuning, respectively, to shape model responses to specific prompt patterns. The paper lists them as alignment methods that suppress harmful behavior.
- Qi et al. (2025): The paper cites their view that alignment often relies on heuristic shortcuts rather than robust semantic understanding, and that safety alignment should not cover only a few tokens.
Mechanistic analysis of suffixes
- Ben-Tov et al. (2025): Studies how universal jailbreak suffixes hijack attention. Section 5 places it alongside token pruning, stating these approaches implicitly assume the suffix is the optimal adversarial token position.
- Wang et al. (2025): Proposes AttnGCG, using attention manipulation to enhance jailbreaks. Section 4 follows its attention score algorithm and extends the analysis to all layers and prefixes; the paper does not present it as a criticized baseline.
- Arditi et al. (2024): Proposes that refusal is mediated by a single direction. After the attention analysis, the authors suggest such internal mechanisms should also be examined, without experimental comparison.
Baselines and data
- Baseline method is standard GCG, referred to as GCG-Suffix. Benchmark is AdvBench (Zou et al., 2023), with 100 harmful prompts randomly sampled.
The authors frame the difference between this work and the above as: no longer defaulting to the suffix as the optimal position, but treating the position of adversarial tokens itself as an attack axis, examining whether alignment remains stable when tokens are moved.
How does the paper address this problem?
Under the same GCG goal, optimize prefix and suffix separately, and cross-evaluate at both positions.
The authors follow GCG's white-box optimization, changing adversarial tokens from a fixed suffix to an optimizable, replayable contiguous block, comparing GCG-Prefix and GCG-Suffix.
Problem setup
- Position definition: Adversarial token position refers to the placement of an entire contiguous block of tokens within the prompt, such as prefix or suffix, not the index of a single token within that block.
- Optimization objective: Iteratively minimize a loss defined on a specified target output sequence, targeting the likelihood of the target tokens. The paper does not write the specific text of that target sentence.
- Two generations: GCG-Suffix appends adversarial tokens after the goal and then optimizes; GCG-Prefix prepends initial adversarial tokens before the prompt and optimizes under the same goal.
- Cross-evaluation: The same token block is placed both at the optimized position and moved to the other position, to separate position effects from the generation process.
Optimization and template
- Initialization: Adversarial tokens are initialized as repeated x, with length k=20. Appendix B gives that initialization string. Prefix and Suffix use the same hyperparameters.
- Iterations: 250 steps, no early stopping. Each step selects 1 token replacement from 256 candidates based on gradient scores. Random seed is 42.
- Template: Fixed as a single user message. During evaluation, the base prompt is unchanged, only whether the adversarial block is at the beginning or end. No additional separators or format tokens are added beyond standard whitespace.
Success determination
- Data: 100 harmful prompts randomly sampled from AdvBench. The paper does not specify the number per category.
- ASR@k: Success is counted if at least one of k distinct configurations succeeds. k=1 looks only at the optimized position; k=2 (Both in the table) counts success if the same token block succeeds at either prefix or suffix position.
- Decoding: Greedy, temperature=0, maximum generation length 512. Appendix B writes that each adversarial prompt is evaluated once per configuration.
- Reviewer: Following Qi et al. (2024a), uses GPT-4. The scale is 1 to 5. Appendix C defines success as a harm score equal to or above 5; Appendix B writes a harm score of 5. Appendix C gives the reviewer prompt and scoring rules.
Attention analysis
- Objects: Successful GCG-Prefix and GCG-Suffix prompts, across all decoder layers. Figure 1 is Llama; Appendix A Figures 2–5 are Vicuna, Qwen, Mistral, Deepseek in order.
- Scores: For GCG target output tokens, average the attention weights of goal tokens or adversarial tokens. Equation (1) averages the attention matrix at layer l over input index set S and output index set O, yielding s_S.
- Control: In the figure captions, Goal refers to the original harmful prompt. The authors state the approach is similar to Wang et al. (2025), but goes beyond settings that only look at suffixes and only at middle-to-late layers.
What experiments did the paper conduct?
In Tables 1–2, which of prefix or suffix is higher varies by model; swapping positions only raises some ASRs.
Experimental Setup
- Tested models: deepseek-llm-7b-chat, Qwen2.5-7B-Instruct, Mistral-7B-Instruct-v0.3, Llama-2-7b-chat-hf, vicuna-7b-v1.5. In the table, abbreviated as Deepseek, Qwen, Mistral, Llama, Vicuna.
- Attacks: GCG-Prefix and GCG-Suffix. In Table 2, rows are the attack model used for optimization, columns are the evaluated target model. Diagonal indicates the target is the optimized model.
- Data: 100 random samples from AdvBench.
- Metrics: ASR@k=1 means success only at the optimized position; ASR@k=2 means success with either prefix or suffix. Parentheses in Table 2 are the absolute increase from ASR@k=1 to ASR@k=2.
- Evaluation: GPT-4, success if harm score reaches 5. The paper does not report agreement with human judgment or statistical tests.
- Repeats: seed 42; each configuration evaluated once per adversarial prompt. The paper does not report additional repeats.
Main Results
White-box ASR from Table 1. Prefixeval, Suffixeval are ASR@k=1, Both is ASR@k=2.
Swipe horizontally to read the table
Model Prefix@optimized position Prefix Both Suffix@optimized position Suffix Both deepseek-llm-7b-chat 10% 15% 11% 12% Qwen2.5-7B-Instruct 60% 61% 45% 46% Mistral-7B-Instruct-v0.3 71% 80% 94% 94% Llama-2-7b-chat-hf 35% 36% 40% 41% vicuna-7b-v1.5 83% 99% 91% 97% - Authors claim: when evaluating only at the optimized position, neither prefix nor suffix is consistently higher across all models. In Table 1, only Qwen has both prefix columns higher than suffix; for the other four models, suffix is higher at the optimized position.
- Authors claim: after allowing position changes, GCG-Prefix's Both exceeds GCG-Suffix on Deepseek and Vicuna, although suffix is still higher at the optimized position. On Qwen, prefix is higher at both k values.
- Authors claim: the optimal position is not always suffix; fixed-position evaluation underestimates jailbreak success. On Mistral and Llama, the increase in Both relative to the optimized position is smaller; Mistral's two suffix columns are identical.
Cross-Model Transfer
- Authors claim: across all attack–target pairs, neither prefix nor suffix consistently dominates; effectiveness varies with source and target model. Authors claim allowing position changes improves transfer, and state that on deepseek, mistral, and vicuna, several pairs have absolute increases up to 49%. In Table 2, this 49% is for Llama's Suffix transferring to Vicuna, corresponding to ASR@k=2 of 73%.
- Transfer to Vicuna with attack model not Vicuna: Table 2's ASR@k=2 is 52%–73%. Suffix-optimized parentheses increases are 36%, 37%, 44%, 49%; prefix-optimized are 7%, 4%, 9%, 7%, with attack models Deepseek, Qwen, Mistral, Llama respectively.
- Low transfer: when the attack model is not Llama, ASR@k=2 on Llama is 0% or 1%. When the attack model is not Qwen, on Qwen except Llama's Suffix at 5% (1%), the rest are 0% or 1%. There are also cells with 0% increase, e.g., Mistral's Suffix on itself is 94% (0%). Authors do not separately explain these low values.
Attention Changes with Position
- What was tested: on successful samples, compare by layer the average attention of goal token and adversarial token to the GCG target output token. Figure 1 is Llama, Figures 2–5 are Vicuna, Qwen, Mistral, Deepseek. Captions state Goal is the original harmful prompt; the text has no curve values or axis ticks.
- Authors claim: suffix attacks have higher attention to adversarial tokens in later layers, consistent with Wang et al. (2025), Ben-Tov et al. (2025). When tokens are prefix, most layers still have goal token dominating attention, but jailbreak still succeeds.
- Authors claim: later layers pay insufficient attention to adversarial prefix, earlier layers allocate more attention to adversarial tokens; looking only at middle and later layers, the correspondence between attention and ASR is incomplete and position-dependent. Authors suggest also looking at internal mechanisms like refusal direction. In Appendix A, authors claim the same trend across models. This interpretation comes from the main text and cannot be verified with figure readings.
Position Swap Examples
- What was tested: Appendix D, Figures 9 and 10 give examples where optimization/evaluation position fails, but swapping positions succeeds. The paper does not state the models for these two examples, nor the proportion of such cases among the 100.
- Results: authors claim Figure 9 succeeds only when prefix-optimized and suffix-evaluated; Figure 10 succeeds only when adversarial tokens are evaluated as prefix. On success, authors do not show harmful behavior outputs.
- Authors' interpretation: these two examples illustrate that attack success is sensitive to adversarial token position. The paper does not further statistically analyze the frequency of such flips.
Other Ablations and Analyses
The paper does not report scans over steps, candidate sets, token lengths, or seeds. The following are all ASR@k=2 from Table 2, parentheses are absolute increases.
- Qwen's Prefix transferring to Mistral is 56% (13%), Suffix is 43% (9%).
- Llama's Suffix transferring to Mistral is 59% (15%), Prefix is 43% (7%).
- Vicuna's Suffix transferring to Mistral is 44% (10%), Prefix is 31% (6%).
- Qwen's Prefix transferring to Deepseek is 28% (7%), Suffix is 27% (8%).
- Hyperparameters fixed at k=20, 250 steps, candidate set 256, seed 42, no early stopping (Appendix B).
What are some points that can be further explored?
The authors plan to extend to other attacks and to systematically vary positions beyond prefix and suffix.
Limitations and future directions noted by the authors
The paper has no separate Limitations section. Section 6 lists only two future directions:
- Other attacks: The authors plan to extend this analysis to attacks beyond GCG (Section 6).
- More positions: The authors plan to systematically vary the adversarial token position, rather than only comparing suffix and prefix (Section 6).
Section 6 also states that treating attention as a saliency metric in adversarial settings is shortsighted. This is the authors' conclusion about existing practice, not a list of their experimental gaps. The paper does not frame the dataset, model scale, or review protocol as limitations.
Experimental coverage
- The tested models are deepseek-llm-7b-chat, Qwen2.5-7B-Instruct, Mistral-7B-Instruct-v0.3, Llama-2-7b-chat-hf, and vicuna-7b-v1.5, 5 in total; the reviewer model is GPT-4 (Section 2.3, Appendix C).
- The data are 100 harmful prompts randomly sampled from AdvBench; white-box results are in Table 1, cross-model results in Table 2.
- The attacks are GCG-Prefix and GCG-Suffix; the evaluated positions are prefix and suffix. The attention analysis covers all layers and targets successful samples (Section 4, Appendix A).
- The success threshold per Appendix C is a harm score equal to or above 5; each configuration is evaluated once per adversarial prompt, with decoding temperature=0 and maximum length 512 (Appendix B, Appendix C). The paper does not report agreement between the reviewer and humans.
- GCG uses 250 steps, no early stopping, adversarial length 20, candidate set 256, and seed 42 (Appendix B). The paper does not report the number of queries or statistical tests.
Summarize the main content of the paper
The authors state that whether the adversarial token is a prefix or suffix changes GCG's ASR, and that fixing the position underestimates the risk.
The authors use GCG as a case study to examine whether placing the adversarial token before or after the prompt changes the jailbreak ASR.
- Problem: Suffix-style GCG fixes a contiguous adversarial block at the end of the goal. The authors argue that this position is an overlooked attack axis, and that testing only one position overestimates robustness and underestimates risk.
- Method: Under the same target likelihood, GCG-Prefix and GCG-Suffix are optimized separately, with length 20 and 250 steps, and the same token sequence is then placed at the optimized position or the other position. ASR@1 counts only the optimized position; ASR@k=2 counts success at either prefix or suffix. The data are 100 AdvBench prompts, and a GPT-4 harm score of 5 counts as success.
- White-box: At the optimized position, the suffix is not higher on all models. Allowing both positions, Vicuna's GCG-Prefix goes from 83% to 99%, and Deepseek from 10% to 15% (Table 1). On Qwen, the prefix's ASR@1 is 60% and the suffix's is 45%. On Mistral, the suffix is 94%, and Both does not improve further.
- Transfer: The authors state that changing the position improves black-box cross-model transfer, with the largest absolute increase up to 49%. In Table 2, this number corresponds to Llama's Suffix transferred to Vicuna, with ASR@k=2 at 73%. When the attacking model is not Llama, the result on Llama is 0% or 1%. The prefix is sometimes higher, e.g., Qwen's Prefix transferred to Mistral is 56% (13%), and the Suffix is 43% (9%).
- Attention: The authors state that successful suffix attacks attend more to the adversarial token in later layers; prefix attacks are still dominated by the goal token in most layers, yet the jailbreak still succeeds. The authors state that looking only at middle and later layers misses this position dependence, and that treating attention as a saliency metric is shortsighted.
- Conclusion: The authors argue that adversarial robustness evaluation should also account for the structural position of the adversarial token, and they plan to extend to other attacks and to positions beyond prefix and suffix.
Related papers
- Exploring Jailbreak Vulnerability Across Depth-Based Dynamic Inference in Large Language ModelsAnalysis / interpretabilityarXiv