TL;DR
MEMBRANE is a self-evolving external guardrail designed to protect LLMs and autonomous agents from rapidly changing jailbreak attacks without requiring model retraining. By utilizing a Contrastive Safety Memory (CSM) that pairs harmful attack patterns with superficially similar benign requests, it successfully blocks adversarial exploits while dramatically reducing the "over-refusal" problem common in traditional guardrails.
What Problem Does This Paper Address?
As Large Language Models (LLMs) and AI agents are increasingly deployed in real-world applications, they face a continuous barrage of adversarial "jailbreak" attacks. These attacks constantly evolve, moving from simple prompt modifications to complex, multi-step persuasion tactics and automated policy exploration.
Traditional defenses typically rely on fixed safety classifiers or fine-tuning, which are rigid and expensive to update post-deployment. To fix this, researchers have turned to memory-augmented guardrails that store safety rules dynamically. However, existing memory-based systems suffer from a major flaw: they only store "one-sided" safety knowledge (i.e., what to block). Lacking explicit context on what is safe, these guardrails frequently over-react, erroneously rejecting harmless user queries that happen to share surface-level vocabulary or phrasing with known attacks—a phenomenon known as over-refusal.
Methods
The authors introduce MEMBRANE, an adaptive guardrail centered around a novel Contrastive Safety Memory (CSM) architecture.
MEMBRANE operates in two distinct phases:
- Inference Phase (Guardrail): When a user submits a query, MEMBRANE employs a two-stage retrieval pipeline. First, a vector database performs high-recall retrieval to find relevant memory cells. Second, an LLM-based Retrieval Critic filters out false positives. The remaining cells serve as grounding context for the Guard, which makes the final SAFE or UNSAFE decision.
- Paired Self-Evolution Phase (Learning): Instead of retraining model weights, MEMBRANE updates its memory store dynamically based on deployment experience. When an interaction occurs, a Memory Planner evaluates the outcome and decides whether to
CREATE,UPDATE,DELETE, orSKIPa memory cell. A Memory Writer then synthesizes or refines the cell content.
Each contrastive memory cell contains:
- Attack Profile: Indexes the cell by its abstract attack strategy (e.g., persuasion, role injection) rather than its specific topic.
- Decision Criteria: Explicitly pairs unsafe conditions (
d_unsafe) with benign exemptions (d_safe). - Tool-Action Context: (For agent settings) Maps out specific tool execution boundaries.
Datasets
MEMBRANE was evaluated across both model-level and agent-level safety benchmarks:
- HarmBench: A standard model-level safety benchmark. Because it lacks paired benign queries, the authors synthesized 320 surface-similar benign counterparts to rigorously test over-refusal.
- AgentHarm: An agent-level safety benchmark featuring 176 harmful prompts paired with 176 benign tool-use tasks.
- XSTest & OR-Bench-Hard: Independent, externally authored over-refusal baselines used to verify that the guardrail doesn't over-block standard benign traffic.
Key Insights and Ideas
- Contrast is Critical for Precision: By explicitly documenting the boundary between a harmful exploit and its harmless twin, the guardrail learns exactly where to draw the line, preventing blanket refusals of benign research or creative queries.
- Strategy Over Subject Matter: Indexing memory cells by the mechanism of the attack (e.g., Payload Splitting) rather than the topic (e.g., cybercrime) allows a single memory cell to generalize across completely different subjects.
- Rapid Sample Efficiency: MEMBRANE exhibits a sharp learning curve. As shown in the paper's warmup analysis, the majority of safety gains materialize within the first few interactions because subsequent variations of an attack strategy trigger memory updates rather than creating redundant cells.
Key Results
- State-of-the-Art Defense: MEMBRANE achieved the highest F1 scores across all six modern jailbreak transformations tested on both HarmBench and AgentHarm.
- Drastic Reduction in Over-Refusal: On AgentHarm, MEMBRANE kept benign over-refusal down to 7–14%. In comparison, prior memory-augmented baselines rejected 28–53% of benign queries, and static guards rejected a staggering 73–85%.
- Zero-Day Adaptation: When deployed on live streams of entirely unseen "zero-day" attacks, online self-evolution improved the guardrail's F1 score in 11 out of 12 evaluation streams.
- Robustness: The system retained 87–88% of its F1 performance under cross-attack memory transfer and demonstrated strong stability against adversarial memory poisoning.
Limitations and Future Work
- Language and Modality: The current implementation is restricted to text-only English benchmarks. Expanding to cross-lingual and multimodal agent settings remains future work.
- Inference Overhead: Operating the full pipeline requires two sequential LLM calls (Critic + Guard), which increases latency. While the authors demonstrated a faster "lite" version that bypasses the critic, optimizing the core architecture for production environments is still an open challenge.
- Adaptive White-Box Adversaries: The threat model assumes the adversary does not have direct access to the guard prompt or the memory store itself. Defending against an attacker who can directly manipulate or exploit the contrastive safe-side criteria is a critical direction for future research.
Summary updated