Training Against the Hijack, Not the Suffix

Jailbreak suffixes are short strings of optimized tokens appended to a harmful request so that a safety-tuned language model answers it anyway. Recent interpretability work shows that many of them succeed through one narrow channel. Attention, the mechanism by which each token decides which earlier tokens to read from, gets pulled almost entirely onto the suffix at the few "chat template" tokens that mark the start of the assistant's reply. The harmful request and the system prompt are crowded out, and the model's internal refusal signal never switches on. Two families of defense have grown up around this finding, and both have a weakness. Inference-time edits to attention cost nothing to run, but they have mostly been tested against attackers who do not know the edit is there. Adversarial training, where the model is trained on attacks found during training, is too expensive at LLM scale because finding each discrete attack takes hundreds of model evaluations. It has also been broken by simple adaptive attacks anyway.

This note proposes to bring the two together. If the hijack runs through one measurable channel, the expensive part of adversarial training (searching over discrete tokens for a jailbreak) can be replaced by a cheap continuous search over embeddings that directly maximizes attention dominance at the template tokens. The model is then trained, through a small set of learned anchor vectors and low-rank attention updates, to keep refusing under that worst-case hijack. The bet is that attacking the mechanism instead of the output covers the space of discrete suffix attacks well enough for robustness to transfer to defense-aware attackers. It should do this at a small fraction of the cost of discrete adversarial training and without the fixed, global distortions of inference-time attention edits.

Core Claim

Several papers motivate the claim that the mechanism is concentrated. Universal Jailbreak Suffixes Are Strong Attention Hijackers uses attention knockout and a Dominance Score to show that suffixes act in a shallow regime, relying on information flow from the suffix into the final template tokens. Attention Slipping shows that attention on the harmful instruction drops across gradient, template, and many-shot attacks. Refusal in Language Models Is Mediated by a Single Direction shows that refusal hinges on one internal direction that suffixes keep from activating.

A dominance-maximizing continuous adversary therefore targets the quantity that discrete attacks must change in order to succeed. Training the model to refuse under that adversary should transfer to discrete adaptive attacks, including logprob-guided random search, attention-aware GCG variants, and attacks optimized through the defense itself. The prediction can fail in two ways, and both are informative.

The first possible failure comes from the perturbation-fragility literature. APBench and IMPRESS show that small continuous perturbations are often high-frequency shortcuts that do not reflect the structure of real inputs. Robustness to continuous embedding perturbations could likewise be shortcut robustness that discrete tokens simply route around.

The second possible failure is that a trained defense shuts the attention channel while attackers move to another route. Candidates include dilution over long dialogues (Multi-Turn Jailbreaking via Attention Shifting), nesting inside benign sub-tasks (Feint and Attack), or response prefilling, which works because alignment is only a few tokens deep (Safety Alignment Should be Made More Than Just a Few Tokens Deep).

The proposal is built to tell these outcomes apart. It does so by measuring dominance scores on the attacks that still succeed after training.

Research Program

The work starts with an audit, because the training method only matters if free defenses fail. We take Attention Sharpening from Attention Slipping, which sets the softmax temperature to $T<1$ in every head. We take Hijacking Suppression from Universal Jailbreak Suffixes, which scales down dominant attention vectors. We also take Dynamic Attention from Improving the Robustness of Transformer-based LLMs with Dynamic Attention, which masks the most-attended tokens and randomizes how many are masked. Dynamic Attention was originally tested only on BERT, GPT-2, and T5 against synonym attacks.

We attack all three with defense-aware adversaries. One is GCG run through the modified forward pass. Another is AttnGCG (AttnGCG), whose auxiliary loss explicitly pushes attention onto the suffix. A third is GCG-Hij. The last is the logprob random search with formatting templates and self-transfer from Jailbreaking Leading Safety-Aligned LLMs with Simple Adaptive Attacks, which reached 100% success on the adversarially trained R2D2. For the randomized Dynamic Attention, the gradient attacks average over its randomness, a technique known as expectation over transformation. This follows the adaptive evaluation that exposed the directional-bias defense in Adversarial Attacks Already Tell the Answer.

The core method follows. Let $x$ be a harmful prompt in chat format. Let $\delta$ be a continuous perturbation of the embeddings of a suffix span of length $L$, bounded to a per-token $\ell_2$ ball $\Delta$ around actual token embeddings. Let $\phi$ be the trainable parameters. These are $K$ anchor vectors inserted at the template boundary, in the spirit of Robustness Tokens, plus low-rank updates to the attention projections in the layers where the audit locates dominance. Let $D_\phi(x,\delta)$ be the attention-weighted share of the template tokens' input that comes from the suffix span, following the Dominance Score. Let $r$ be a refusal response, and let $(x_b, y_b)$ be benign prompts paired with the original model's answers. The training objective is

$$\min_\phi \; \mathbb{E}_x\Big[\max_{\delta\in\Delta}\big(\lambda D_\phi(x,\delta) - \log p_\phi(\neg r\mid x\oplus\delta)\big)\text{-optimal } \delta^\star:\; -\log p_\phi(r\mid x\oplus\delta^\star)\Big] + \mathbb{E}_b\big[-\log p_\phi(y_b\mid x_b)\big].$$

In words, the inner adversary takes a few projected-gradient steps that increase the suffix's dominance at the template tokens while lowering the probability of refusing. Here $\lambda$ weights the dominance term and $\neg r$ denotes non-refusal. The outer step trains $\phi$ to refuse anyway, while keeping benign behavior close to the original model.

The inner search is a few forward and backward passes over a short sequence. By contrast, each GCG step scores many candidate token swaps, and Towards Improving Adversarial Training of NLP Models identifies that kind of search as the reason textual adversarial training is intractable. We will measure the saving in GPU-hours rather than assume it.

The benign term is there because adversarial training of LLMs tends to cause over-refusal (HarmBench; Adversarial Déjà Vu). We treat the anchors as public. Robustness Tokens drew part of its security from keeping its tokens secret, and we do not want to rely on that.

The mechanism analysis comes last. For every attack that succeeds against the trained model, we record its dominance score, its attention rate on the harmful instruction, and the projection onto the refusal direction. We also measure how fragile it is. Following Mask-GCG, which found that about 17% of suffix tokens are redundant, we check how much success is lost under random token deletion. Fragile, high-dominance survivors mean the continuous adversary missed part of the attention channel. Robust, low-dominance survivors mean attackers have moved to a different mechanism.

The models are Gemma2-9B, Llama3.1-8B, and Qwen2.5-7B, which are the models already used in the attention-slipping and hijacking studies.

Baselines

The naive reference point is the undefended aligned model under the same attack suite. It fixes the ceiling. JailbreakBench reports that a random-search prompt attack reaches 90% attack success on Llama-2-7B, and the simple-adaptive-attack paper reports 100% on Llama-3-8B and others.

The strongest zero-cost competitors are Attention Sharpening and Hijacking Suppression. Sharpening reduced Qwen2.5-7B attack success from 1.00 to 0.11, with AlpacaEval win rate going from about 83% to about 80% (Attention Slipping). Suppression reduced GCG success on Gemma2 from 60% to 9%, with MMLU and AlpacaEval dropping by less than 2% (Universal Jailbreak Suffixes). They are the strongest competitors because they target the same mechanism at zero training cost. We run each with its published hyperparameters and then tune those hyperparameters on a held-out split with the same tuning budget we give our own $\lambda$, $K$, and LoRA rank. Every method then faces the identical adaptive attack suite with identical query and iteration budgets. Beating them means lower HarmBench-classifier attack success under the strongest adaptive attack, at equal or smaller utility loss.

The adversarial-training reference is R2D2 from HarmBench, which trains against a pool of GCG cases. It is reported to fall to 100% success under simple in-context adaptive attacks (Simple Adaptive Attacks). I found no reported GPU-hour figure for R2D2 training on Lacuna, so we will measure its cost on our hardware and set our compute budget to a stated fraction of it. As a data-driven reference we include ASCoT (Adversarial Déjà Vu), which reports 6% over-refusal on XSTest. We will report its data-generation cost alongside its fine-tuning cost.

The ablation that isolates the key ingredient is the same training run with $\lambda=0$. In this version the inner adversary attacks only the refusal likelihood in embedding space, with no dominance term, using an identical number of inner steps and outer updates. A second ablation keeps the dominance term but trains only the anchors and not the low-rank updates. This tells us whether anchoring at the template boundary is enough.

Why not just…?

Why not just use the free inference-time attention defenses? If sharpening or suppression survives defense-aware attack, our method is unnecessary. The audit tests this directly before any training. There are reasons to expect trouble. A fixed global temperature can be folded into the attacker's objective, and a static test-time defense fell to adaptive attack in Adversarial Attacks Already Tell the Answer. In addition, Surgery finds that heads behave non-uniformly, with early layers resisting steering. If the audit shows these defenses holding under GCG-Hij and logprob random search, we would report that and stop.

Why not just do continuous embedding-space adversarial training on the output loss? This is the real threat. Embedding-space adversaries are cheap no matter what objective they use, so the attention term could add nothing. The $\lambda=0$ ablation settles the question. Our hypothesis predicts that the dominance-trained model will show a lower success rate under discrete adaptive attacks. It also predicts that attacks surviving the $\lambda=0$ model will have high dominance scores, meaning that output-only training left the hijack channel open. If the two ablations match, we will say the attention mechanism was a useful diagnostic but not a necessary training signal.

Why not just purify the input with randomized smoothing or perplexity filters? According to JailbreakBench, SmoothLLM struggles against semantic jailbreaks. Attention Slipping notes that SmoothLLM multiplies inference cost by up to roughly 20×. Mask-GCG shows that attackers can cut suffix perplexity by 24% while keeping success. In vision, IMPRESS found that simple transformations do not remove optimized perturbations. We still include SmoothLLM in the adaptive suite as an extra baseline, run at its default sample count.

Why not just adversarially train harder, as R2D2 does? Its discrete inner loop is the cost problem we are trying to remove, and its robustness did not survive a change of attack style. Our compute-matched comparison asks whether a cheaper, mechanism-targeted adversary does at least as well.

Proposed Experiments

The evaluation uses three benchmarks. The first is HarmBench with its Llama-2-13B classifier, which has 93.19% human agreement, at a fixed generation length of 512 tokens, since the HarmBench paper reports that generation length can shift attack success by up to 30%. The second is JailbreakBench's 100 harmful behaviors with their 100 benign counterparts. The third is the 50-behavior AdvBench subset used for random-search attacks. Utility is measured on AlpacaEval, MMLU, and GSM8K, and over-refusal on XSTest. Each attack class is reported separately: white-box GCG, AttnGCG, and GCG-Hij run through the anchors; logprob random search with templates and self-transfer; template attacks (AutoDAN); multi-turn attention shifting; and, as a labeled out-of-threat-model stress test, response prefilling.

The method succeeds if four conditions hold together. Worst-case adaptive attack success must fall below the best tuned zero-cost attention defense under the same attacks. The AlpacaEval drop must be no larger than sharpening's roughly 3 points. XSTest over-refusal must be comparable to ASCoT's 6%. Training must cost a stated, measured fraction of R2D2's GPU-hours.

The decisive mechanistic check is the dominance and fragility profile of the attacks that survive. If survivors are low-dominance and robust to deletion, attackers have moved off the attention channel. In that case the honest conclusion is that attention-targeted training closes one door, and the next threat model has to address dilution and prefilling directly.

References

  1. Universal Jailbreak Suffixes Are Strong Attention Hijackers
  2. Attention Slipping: A Mechanistic Understanding of Jailbreak Attacks and Defenses in LLMs
  3. Refusal in Language Models Is Mediated by a Single Direction
  4. APBench: A Unified Availability Poisoning Attack and Defenses Benchmark
  5. IMPRESS: Evaluating the Resilience of Imperceptible Perturbations Against Unauthorized Data Usage in Diffusion-Based Generative AI
  6. Multi-Turn Jailbreaking Large Language Models via Attention Shifting
  7. Feint and Attack: Jailbreaking and Protecting LLMs via Attention Distribution Modeling
  8. Safety Alignment Should be Made More Than Just a Few Tokens Deep
  9. Improving the Robustness of Transformer-based Large Language Models with Dynamic Attention
  10. AttnGCG: Enhancing Jailbreaking Attacks on LLMs with Attention Manipulation
  11. Jailbreaking Leading Safety-Aligned LLMs with Simple Adaptive Attacks
  12. Adversarial Attacks Already Tell the Answer: Directional Bias-Guided Test-time Defense for Vision-Language Models
  13. Robustness Tokens: Towards Adversarial Robustness of Transformers
  14. Towards Improving Adversarial Training of NLP Models
  15. HarmBench: A Standardized Evaluation Framework for Automated Red Teaming and Robust Refusal
  16. Adversarial Déjà Vu: Jailbreak Dictionary Learning for Stronger Generalization to Unseen Attacks
  17. Mask-GCG: Are All Tokens in Adversarial Suffixes Necessary for Jailbreak Attacks?
  18. JailbreakBench: An Open Robustness Benchmark for Jailbreaking Large Language Models
  19. Surgery: Mitigating Harmful Fine-Tuning for Large Language Models via Attention Sink