NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

EFFICIENT JAILBREAK ATTACK SEQUENCES ON LARGE LANGUAGE MODELS VIA MULTI-ARMED BANDIT-BASED CONTEXT SWITCHING

Aditya Ramesh, Shivam Bhardwaj, Aditya Saibewar, Manohar Kaul

TL;DR

Researchers have developed a new attack method called Sequence of Context (SoC) that bypasses Large Language Model (LLM) safety guardrails by gradually "softening" the model's defenses through a series of strategic, non-malicious queries. By framing this as a Multi-Armed Bandit (MAB) optimization problem, the attack achieves a staggering 95% success rate while being significantly faster and computationally cheaper than current state-of-the-art methods.

The Problem: Static Defenses vs. Dynamic Conversations

LLMs are equipped with safety filters designed to prevent them from generating harmful content, such as instructions for illegal acts or hate speech. Most existing "jailbreak" attacks fall into two categories:

  1. Single-step attacks: Direct prompts that try to trick the model instantly. These are often easily caught by static filters.
  2. Iterative refinement: Using one LLM to repeatedly rewrite a prompt until it bypasses another LLM’s filter. This approach is computationally expensive and slow.

The authors identify a critical gap in these defenses: LLMs are highly sensitive to conversational context. Current safeguards often evaluate prompts in isolation. They fail to account for how a sequence of seemingly "safe" queries can incrementally shift a model's internal state, eventually coercing it into fulfilling a malicious request.

Methods: The Sequence of Context (SoC) Attack

To exploit this vulnerability, the paper introduces the Sequence of Context (SoC) attack. Instead of hitting the model with a Direct Malicious Query (DMQ) immediately, the system sends a series of Context-Switching Queries (CSQs). These CSQs are designed to alter the conversation's framework—for example, by framing the request as a fictional story, a research project, or an authoritative official communication.

Overview of the Sequence of Context (SoC) attack framework using a Multi-Armed Bandit.

To automate this process, the authors utilize a Multi-Armed Bandit (MAB) framework:

  • The "Arms": Seven different categories of CSQ tactics (e.g., Storytelling, Statistical Justification, Ethical Reassurance).
  • The Strategy: An $\epsilon$-greedy algorithm balances exploration (trying different types of context shifts) and exploitation (using the tactics that have historically worked best to "soften" the target model).
  • The Reward: A "Judge" LLM (Llama-3.1-8B) evaluates the target's response and provides a binary reward (1 if jailbroken, 0 if not).
  • The Cost Function: A novel cost function penalizes excessive exploration, keeping the attack sequence as short and efficient as possible.

Datasets and Tactics

The study utilized a comprehensive dataset of 2,700 Direct Malicious Queries (DMQs) aggregated from existing benchmarks. To generate the attack sequences, the authors created a library of CSQ templates across seven categories: Context Misdirection, Emotional Engagement, Storytelling, Authority Imposition, Conflicting Choices, Ethical Reassurance, and Statistical Justification.

Key Insights: The "Boiling Frog" Effect

  • Contextual Erosion: The most profound insight is that safety is not a static wall but a boundary that can be eroded. By gradually introducing ambiguous or contradictory contexts, the attacker "softens" the model’s adherence to safety guidelines.
  • The "Boiling Frog" Effect: By the time the actual malicious query is asked, the model has already committed to a persona or context (like being a "renowned researcher") that makes refusal feel "out of character" for the established dialogue.
  • Model-Specific Vulnerabilities: The MAB approach revealed that different models are susceptible to different tactics. For instance, Llama-3.1-8B-Instruct was frequently swayed by "Ethical Reassurance" in early steps, while Mistral-7B was more vulnerable to "Statistical Justification."
  • Black-Box Efficiency: Unlike optimization-based attacks (like GCG) that require white-box access to model weights, SoC is a black-box attack requiring only API access, making it remarkably fast and practical.

Key Results

The SoC attack outperformed all major baselines across multiple open-source models, including various Llama and Mistral variants.

Mean Attack Success Rate (ASR) across different SoC attack sequence lengths.
  • Attack Success Rate (ASR): The method achieved an impressive 95% ASR, vastly surpassing PAIR (31.85%), AutoDAN (35%), and ReNeLLM (45%). As shown in the data, the ASR scales reliably with the length of the attack sequence.
  • Efficiency: The Cost Per Prompt (CPP) was only 15 seconds, compared to 132 seconds for ReNeLLM and a massive 955 seconds for AutoDAN.
  • Generalization: Using 5-fold cross-validation, the authors proved the learned MAB policy generalizes well to entirely unseen categories of malicious queries.
  • Scalability: The attack remained highly effective even as model parameter sizes increased, successfully compromising models up to 70B parameters.

Limitations and Future Work

While highly effective, the current method relies on a fixed database of CSQ templates. The authors suggest that integrating a dynamic generator (like a Q-learning agent) could further increase the variety and potency of the attacks. Additionally, the "Judge" LLM can sometimes misclassify responses, adding noise to the MAB training process.

Ultimately, this paper highlights a massive vulnerability in modern AI: current safeguards are too static. Future defense research must focus on sequential monitoring—analyzing the entire conversation history for "context-shifting" patterns rather than just checking the most recent prompt in isolation.

Summary updated

BibTeX
@inproceedings{ramesh2025efficient,
  author = {Aditya Ramesh and Shivam Bhardwaj and Aditya Saibewar and Manohar Kaul},
  title = {{EFFICIENT JAILBREAK ATTACK SEQUENCES ON LARGE LANGUAGE MODELS VIA MULTI-ARMED BANDIT-BASED CONTEXT SWITCHING}},
  booktitle = {International Conference on Learning Representations},
  year = {2025},
  url = {https://openreview.net/forum?id=jCDF7G3LpF},
}
Figure