TL;DR
This paper introduces a novel attack surface in LLM agents: prompt compression. They demonstrate that by subtly perturbing untrusted inputs before compression, attackers can trick the compressor into discarding crucial safety guardrails or task-critical information, leading to downstream misbehavior. Their proposed attack, COMA, effectively exploits this vulnerability, achieving significantly higher success rates than existing methods.
What Problem Does This Paper Address?
Large Language Model (LLM) agents are increasingly complex, often assembling various pieces of information (system prompts, user queries, external data) before sending a final prompt to a backend LLM. To manage the growing length of these prompts, which impacts latency and cost, "prompt compression" modules are used. These modules condense the prompt, but the authors argue this process introduces a new security vulnerability. Previously, attacks focused on manipulating the backend LLM directly. This paper highlights that the compressor itself becomes a critical component in the security pipeline. When trusted and untrusted inputs are compressed together under a shared budget, an attacker can manipulate the untrusted parts to influence what the compressor retains, effectively changing the security boundary without directly attacking the LLM.
Methods
The core of the paper is the introduction of Adversarial Information Loss (AIL), a formalization of the vulnerability. AIL quantifies the excess downstream behavioral distortion caused by an attacker steering a lossy compressor beyond what benign compression alone would cause.
To exploit AIL, they propose COMA (Compression Attack), a transfer-based black-box attack. COMA operates in two stages:
- Dropout Target Selection: Using a surrogate LLM and compressor, COMA identifies critical tokens or spans in the prompt that, if removed, would likely induce misbehavior. This is done by greedily deleting tokens from a "clean" compressed prompt until misbehavior is observed.
- Adversarial Perturbation Search: COMA then searches for a perturbation to the original untrusted input that, when compressed by the surrogate compressor, results in the target compressed prompt identified in Stage 1. This search is guided by gradients and uses a greedy token replacement strategy.
Finally, COMA validates the generated adversarial perturbations on the actual black-box victim agent.
Datasets
The paper evaluates COMA on three tasks:
- Agent Tool Selection (ATS): A custom dataset of 249 entries spanning product categories and tool descriptions, designed to test if the LLM selects the correct tool.
- Question Answering (Q&A): A subset of the SQuAD dataset (913 entries) where the passage is treated as untrusted external context.
- System Prompt Corruption (SPC): A dataset of 1563 entries collected from GitHub repositories and the Real-Guardrails benchmark, focusing on guardrail violations.
Key Insights and Ideas
- Prompt compression is not security-neutral: It fundamentally shifts the security boundary from the backend LLM to the entire pipeline, creating a new attack surface.
- Attack the compressor, not the LLM: COMA's effectiveness stems from manipulating the compression process itself, not from crafting complex prompts for the LLM. The perturbation doesn't need to be semantically meaningful or survive compression.
- Adversarial Information Loss (AIL): This formalization is crucial for understanding and quantifying the vulnerability introduced by compression. It isolates the attacker's contribution beyond normal compression-induced distortion.
- Transferability is key: COMA's black-box nature and use of surrogate models allow it to transfer attacks to unseen victim pipelines, making it a practical threat.
- Isolation as a defense: Separating trusted and untrusted inputs before compression significantly improves robustness, particularly for system prompt corruption.
Key Results
- High Attack Success Rate (ASR): COMA achieved an average ASR of 0.71 across six compressors and three tasks, significantly outperforming the strongest non-compression-based baseline (0.21 ASR).
- Generalization: COMA demonstrated strong generalization across different compression budgets (R values) and various backend LLMs (Llama, Mistral, Qwen families of different scales).
- Robustness to Surrogate Mismatch: While using an exact replica of the victim compressor yields the best results, mismatched surrogates still transfer effectively, indicating that precise replication isn't always necessary.
- Effectiveness of Isolation: The proposed "Isolated Compression" (IC) mitigation achieved a Defense Success Rate (DSR) of 0.96 on SPC, significantly outperforming existing defenses.
- Case Studies: COMA successfully transferred to realistic agent pipelines (VSCode Cline, LangChain + Ollama), demonstrating real-world applicability.
Limitations and Future Work
- Surrogate Model Accuracy: The effectiveness of COMA relies on the quality of the surrogate compressor and LLM. While they show good transferability even with mismatches, a highly inaccurate surrogate might limit attack success.
- Computational Cost: The two-stage optimization and search process can be computationally intensive.
- Defense Effectiveness: Existing defenses like perplexity-based methods showed significantly reduced effectiveness under compression. The paper proposes "Isolated Compression" as a promising mitigation, but further research into compression-aware defenses is warranted.
- Future Work: The authors suggest exploring more sophisticated attack strategies, investigating the impact of different compression techniques, and developing more robust and efficient compression-aware defense mechanisms.
Summary updated