Working Memory Attack on LLMs

Bibek Upadhayay, Vahid Behzadan, Amin KarbasiNFAM @ ICLR 2025

TL;DR

This paper introduces a novel "working memory attack" that exploits the in-context learning (ICL) capabilities of LLMs by overloading their processing capacity with irrelevant information. This attack successfully bypasses safety mechanisms in state-of-the-art LLMs, demonstrating a significant vulnerability in how these models handle complex contextual inputs.

What Problem Does This Paper Address?

Large Language Models (LLMs) have demonstrated impressive in-context learning (ICL) abilities, allowing them to adapt to new tasks without parameter updates. However, this flexibility also introduces security vulnerabilities. The paper addresses the problem of how these ICL capabilities can be exploited to compromise LLM safety, specifically by leveraging the concept of working memory limitations, drawing parallels to human cognitive constraints. The authors aim to quantify and exploit these limitations to bypass safety guardrails and generate harmful content.

Methods

The core of the paper's methodology is inspired by neuroscience's "dual-task paradigm" for measuring cognitive load. The authors developed a novel multi-task approach to systematically measure and quantify working memory overload in LLMs. This involves creating complex prompts with a primary task designed to progressively increase task-irrelevant token generation, followed by an "observation task" (which is the actual harmful query). By observing the degradation in performance on the observation task as the primary tasks increase in complexity, they can quantify the working memory load. They then leverage this understanding to craft prompts that overload the LLM's working memory, leading to a breakdown in its safety mechanisms. An automated attack algorithm was developed to systematically test these prompts across various LLMs.

Datasets

  • Vicuna MT Benchmark: Used to curate 100 questions for the observation task.
  • Forbidden Question Set: A subset of harmful questions (232 in total) was used, excluding categories deemed not harmful or effectively answered by SOTA models.
  • JailbreakBench dataset: Consists of 100 harmful questions representing distinct misuse behaviors.
  • Science Experiment Dataset: Used for creating observation tasks in the dual-task approach.

The authors also generated derivative questions from the original harmful questions in a "How to" or "What are" style to potentially evade safety training and to align with the prompt template's structure.

Key Insights and Ideas

  • LLMs have analogous working memory limitations: The research strongly suggests that LLMs, like humans, experience performance degradation when their processing capacity is overloaded with irrelevant information.
  • ICL is a key vulnerability vector: The ability of LLMs to learn from context is precisely what makes them susceptible to this type of attack. By manipulating the context, attackers can induce overload.
  • Task complexity directly impacts performance: Progressively increasing the amount of task-irrelevant information in the prompt leads to a quantifiable decrease in the LLM's ability to perform the observation task accurately.
  • Working memory overload can bypass safety mechanisms: When overloaded, LLMs appear to prioritize processing the complex input over enforcing safety protocols, leading to the generation of harmful content.
  • Higher-capability LLMs can be used to attack others: More advanced LLMs can be leveraged to craft effective working memory overload attacks targeting other models, demonstrating the transferability of this vulnerability.

Key Results

The paper reports extremely high attack success rates (ASR) for their working memory attack across multiple state-of-the-art LLMs, including:

  • GPT-4
  • Claude-3.5 Sonnet
  • Claude-3 OPUS
  • Llama-3-70B-Instruct
  • Gemini-1.0-Pro
  • Gemini-1.5-Pro

Attack success rates reached up to 99.99% for some models. The experiments showed that as the working memory load increased (through more irrelevant tokens), the performance on the observation task significantly degraded. For instance, in the unicorn drawing experiment, higher loads led to abstract or erroneous code generation. Smaller models like Gemini-1.0-Pro and Llama-3-8B-Instruct were found to be more susceptible, experiencing overload earlier in the prompt template progression.

Limitations and Future Work

  • Limited task variety: The study focused on a "handful of tasks" for inducing working memory load and suggested exploring other patterns.
  • Extraneous load variability: The impact of irrelevant tokens on extraneous load can vary across different LLMs. The study used specific tags ([INST], [/INST]), and other tags might be more effective.
  • Task order: The current experiments did not explore the impact of changing the order of tasks within the prompt template.
  • Single-model baseline for load assessment: The initial assessment of cognitive load tasks was limited to a single model (Llama-3-70B-Instruct).
  • Subjectivity in self-reporting: The self-reporting approach for assessing load is subjective and potentially biased by the prompt's information.
  • Cost of derivative questions: Generating non-harmful derivative questions can be costly and impact ASR. Using uncensored LLMs for this is recommended.
  • Absence of human evaluation: The study relied on LLMs as judges, and human evaluation could provide further insights.
  • Judge LLM bias: The outcomes of attacks can vary depending on the judge LLM used, suggesting the need for a jury of judges.
  • Harmfulness evaluation prompt bias: The classification scheme (SAFE/UNSAFE vs. SAFE/UNSAFE/NEUTRAL) can affect ASR.
  • Quality of harmful responses: The study did not measure the quality of the harmful responses generated after a successful jailbreak.
  • Baseline for load quantification: It's difficult to precisely quantify working memory load without a baseline.

Future work could involve exploring more diverse tasks, different obfuscation techniques, varying task orders, and incorporating human evaluation to create more robust defenses against such attacks. The authors also aim to develop countermeasures and enhance LLM resilience.

Summary updated

BibTeX
@inproceedings{upadhayay2025working,
  author = {Bibek Upadhayay and Vahid Behzadan and Amin Karbasi},
  title = {{Working Memory Attack on LLMs}},
  booktitle = {NFAM @ ICLR},
  year = {2025},
  url = {https://openreview.net/forum?id=FS9mwfBQYF},
}
Figure