Accelerating Suffix Jailbreak attacks with Prefix-Shared KV-cache
Xinhai Wang, Shaopeng Fu, Shu Yang, Liangyu Wang, Tianhang Zheng, Di Wang · 2026
Read Accelerating Suffix Jailbreak attacks with Prefix-Shared KV-cache by Xinhai Wang, Shaopeng Fu, Shu Yang, Liangyu Wang, Tianhang Zheng, Di Wang (2026) in the Tower of Babel, a free online library of public-domain works preserved in clean, searchable text. No sign-up. The full text is served as a plain-text file at a predictable URL, where text is present: https://antarctic-labs.com/tower-of-babel/arxiv-2603-13420.txt.
Introduction
Xinhai Wang and co-authors present PSKV, a method to speed suffix jailbreak attacks on LLMs. Such attacks test many candidate suffixes before one works, so costs run high. All candidate prompts share the same harmful instruction as a prefix, the team notes. PSKV keeps one KV cache for that prefix and shares it with every candidate prompt. That cuts redundant inference and allows more aggressive batching within memory limits. On six attacks across five LLMs, it cut inference time by 40 percent and peak memory by half.
Catalog record
| CREATOR | Xinhai Wang, Shaopeng Fu, Shu Yang, Liangyu Wang, Tianhang Zheng, Di Wang |
|---|---|
| YEAR | 2026 |
| COLLECTION | PAPERS |
| FORMAT | TXT |
| FILE SIZE | 57336 |
| LICENSE | http://creativecommons.org/licenses/by/4.0/ |
| RIGHTS | CC BY |
| SOURCE | arXiv |
Source: https://arxiv.org/abs/2603.13420
Browse the full library · About the Tower of Babel
Full text
The opening of the work, from the library's hosted text:
Accelerating Suffix Jailbreak attacks with Prefix-Shared KV-cache Xinhai Wang, Shaopeng Fu, Shu Yang, Liangyu Wang, Tianhang Zheng, Di Wang Abstract Suffix jailbreak attacks serve as a systematic method for red-teaming Large Language Models (LLMs) but suffer from prohibitive computational costs, as a large number of candidate suffixes need to be evaluated before identifying a jailbreak suffix. This paper presents Prefix-Shared KV Cache (PSKV), a plug-and-play inference optimization technique tailored for jailbreak suffix generation. Our method is motivated by a key observation that when performing suffix jailbreaking, while a large number of candidate prompts need to be evaluated, they share the same targeted harmful instruction as the prefix. Therefore, instead of performing redundant inference on the duplicated prefix, PSKV maintains a single KV cache for this prefix and shares it with every candidate prompt, enabling the parallel inference of diverse suffixes with minimal memory overhead. This design enables more aggressive batching strategies that would otherwise be limited by memory constraints. Extensive experiments on six widely used suffix attacks across five widely deployed LLMs demonstrate that PSKV reduces inference time by 40% and peak memory usage by 50%, while maintaining the original Attack Success Rate (ASR). The code has been submitted and will be released publicly. † † affiliationnotice: Equal contribution 1 Introduction Suffix jailbreak attacks, which aim to synthesize jailbreak suffixes to bypass safety guardrails and elicit harmful content, have become a vital component for red-teaming Large Language Models (LLMs) ( 17 ; 1 ) . Current approaches primarily employ heuristic search ( 17 ; 16 ) or LLM-based generators ( 9 ) to generate these suffixes. However, a major bottleneck of these methods is their prohibitively high computational cost. Standard optimization-based attacks must iteratively evaluate a vast number of candidate suffixes against the target LLM to identify effective jailbreaks. While LLM-based generators offer faster test-time suffix generations, they merely shift the computational burden to the training phase, which still necessitates time-consuming suffix generation to construct training data. Ideally, Key-Value (KV) caching could accelerate this evaluation process by reusing intermediate tensors. However, in jailbreak scenarios, the system prompt is typically far longer than the suffix. Standard KV cache implementations must duplicate this long prompt’s cache for every candidate suffix in a batch, inducing excessive memory consumption that limits batch size. While state-of-the-art inference systems like vLLM ( 6 ) and SGLang ( 15 ) address these memory constraints through careful memory scheduling, they are designed strictly for forward-pass inference. Their highly encapsulated interfaces and lack of backpropagation kernels prevent access to gradients, restricting their utility to a subset of gradient-free attacks ( e.g. , BEAST attack ( 11 ) ). Consequently, these limitations collectively impede the effective acceleration of general suffix jailbreak attacks. To overcome these limitations, we propose Prefix-Shared KV Cache (PSKV) , a lightweight, workload-aware, and plug-and-play framework tailored for accelerating suffix jailbreak attacks. Our method is motivated by a key structural redundancy in jailbreak optimization: while a batch of candidate suffixes varies, they typically share an identical targeted harmful instruction as the prefix. Standard KV cache implementations ignore this property, redundantly duplicating the long prefix cache for every candidate. In contrast, PSKV maintains a single, shared KV cache for the invariant prefix and broadcasts it to all candidate suffixes during inference. By employing a suffix-centric alignment strategy, PSKV supports dynamic expansion and parallel batched loss computation. Crucially, unlike encapsulated inference engines, PSKV integrates seamlessly into existing attack pipelines, ensuring substantial acceleration and minimal memory overhead while preserving gradient access. We evaluated PSKV across six widely used suffix jailbreak attacks and five popular open-source models. We compared our framework against a baseline without KV cache and a standard KV cache implementation. The results demonstrate that PSKV reduces inference time by approximately 40\% compared to the no-cache baseline and decreases peak memory usage by 50\% compared to the standard KV cache implementation. Furthermore, because PSKV is a drop-in optimization that does not alter the high-level logic of the attack, it maintains the original Attack Success Rate (ASR). This efficiency enables researchers to scale evaluations to larger models and broader search spaces that were previously computationally prohibitive. In summary, our contributions are: • We identify the inefficiency of general-purpose inference caching when applied to the specific structural patterns of jailbreak suffix optimization. • We propose PSKV, a memory-efficient framework featuring virtual cache broadcasting and suffix-centric tensor alignment to eliminate redundant computations. • We conduct comprehensive evaluations demonstrating that PSKV substantially reduces both computational and memory costs, paving the way for a scalable LLM vulnerability assessment. 2 Related Work Automated Suffix Jailbreaking. Recent research has transitioned from manual red-teaming to automated adversarial optimization. The foundational method, GCG ( 17 ) , employs a greedy, gradient-guided search to iteratively refine an adversarial suffix. Building on this, subsequent works have explored more sophisticated search strategies. BEAST ( 11 ) replaces the greedy algorithm with beam search to explore a wider range of promising candidates. Zhu’s AutoDAN ( 16 ) utilizes genetic algorithms to evolve suffixes, mitigating the local optima problem of purely greedy methods. Other variants like GCQ (Gradient-based Attack with Quantization) ( 4 ) focus on improving the efficiency of the core gradient-based update step itself. An alternative paradigm uses LLMs themselves as generators. AdvPrompter ( 9 ) fine-tunes a language model to automatically compose adversarial prompts. Similarly, AmpleGCG trains a generative model to directly output effective suffixes, amortizing the search cost into a one-time training process ( 7 ) . Although these methods differ, they all require evaluating a large number of candidate suffixes to create a training set during either the model training or data generation phases. Our work presents an orthogonal optimization that accelerates this critical evaluation step, benefiting both categories of attack. Efficient Inference & KV Caching. Optimizing Key-Value (KV) cache management is central to high-throughput LLM serving. vLLM ( 6 ) introduced PagedAttention to mitigate memory fragmentation in multi-user scenarios, while SGLang ( 15 ) employs RadixAttention to automatically detect and share prefixes across diverse incoming requests via a radix tree structure. ChunkAttention ( 14 ) further optimizes memory locality. However, these systems are architected for asynchronous, multi-user serving , prioritizing request scheduling and fairness over raw batch latency. Applying them to the synchronous, tight-loop nature of adversarial attacks introduces unnecessary overhead (e.g., complex tree lookups, scheduler latency). In contrast, PSKV is a workload-specific optimization that hard-codes the ”one-prefix-many-suffixes” pattern directly into the inference kernel, bypassing the complexity of general-purpose serving engines to achieve maximum efficiency for attack loops. 3 Preliminaries Figure 1: The computational pipeline of iterative suffix attacks. As illustrated in Fig 1 , the workflow of a typical suffix-based jailbreak attack operates as an iterative cycle comprising three distinct phases: heuristic candidate generation, batched forward pass evaluation, and candidate selection. This pipeline forms the operational basis for the optimization problem defined below. Adversarial Suffix Optimization. We consider an LLM as a conditional distribution p_{\theta}(y|x) over a vocabulary \mathcal{V} . Given a harmful query x^{(h)} (e.g., “How to build a bomb”) and a target response y^{(h)} , the goal of a suffix attack is to find an adversarial sequence x^{(s)}\in\mathcal{V}^{L} that maximizes the target probability: \displaystyle x^{(s)*}=\mathop{\arg\max}_{x^{(s)}\in\mathcal{V}^{L}}\log p_{\theta}(y^{(h)}|x^{(h)}\oplus x^{(s)}), (1) where \oplus denotes concatenation. Solving Eq.