Skip to content
Conference Open access

RLShield: Dynamic Jailbreak Detection for LLMs via Reinforced Adaptive Learning

2026 · Annual Meeting of the Association for Computational Linguistics · pp. 23615-23630 · 0 citations · 40 references
Computer Science

TL;DR

RLShield is a dynamic jailbreak detection framework that employs reinforcement learning for adaptive threshold selection and incorporates three key innovations: a dynamic retrieval and LLM-based rewriting module to simulate diverse adversarial contexts; a cross-layer representation analysis to pinpoint safety-critical parameters; and a Soft Actor-Critic based agent that learns to predict optimal, sample-specific detection thresholds.

Abstract

While prompt engineering enhances the capabilities of Large Language Models (LLMs), it also exposes critical safety concerns. Due to the inherent brittleness of their static safety boundaries, LLMs are vulnerable to jailbreak prompts , i.e. adversarial inputs designed to by-pass safeguards and induce the generation of harmful content. Existing detection mechanisms rely on static model components or fixed decision thresholds, limiting their ability to generalize to evolving attack patterns and continual model updates. To bridge this gap, we propose RLShield , a dynamic jailbreak detection framework that employs reinforcement learning for adaptive threshold selection. RLShield incorporates three key innovations: ( i ) a dynamic retrieval and LLM-based rewriting module to simulate diverse adversarial contexts; ( ii ) a cross-layer representation analysis to pinpoint safety-critical parameters; and ( iii ) a Soft Actor-Critic (SAC) based agent that learns to predict optimal, sample-specific detection thresholds. Experimental results demonstrate that RLShield consistently outperforms state-of-the-art base-lines in detection performance while maintaining high computational efficiency. Notably, it improves F1 by up to 7.3%, while achieving an average of 3 × gain in inference efficiency across multiple LLM backbones. Our codes are available at this website.

Read PDF

Similar papers

Open access Aug 2026

D2ANN-RL: Defense-in-Depth ANN-Reinforcement Learning Framework for LLM Chatbot Code Injection Mitigation

The growing cybersecurity vulnerabilities in artificial intelligence (AI) service models, particularly Large Language Models (LLMs), highlight code injection as a critical threat to chatbot reliability and safe deployment. On the account that LLMs process inputs as undifferentiated token sequences, they cannot reliably distinguish trusted system prompts from untrusted user inputs. This architectural limitation enables attackers to exploit direct and indirect prompt injection channels, resulting in insecure code generation, altered execution flows, and potential data exfiltration or remote code execution. In mission critical environments such as cloud platforms, IoT ecosystems, and defense systems, these risks escalate into unauthorized access and operational compromise. To address this challenge, the present study introduced a D2ANN-RL framework that integrates input/output sanitization, context isolation, sandboxing, and secure prompt engineering, supported by hybridization of Artificial Neural Network (ANN)–Reinforcement Learning (RL) detection model. The ANN component ensures robust feature extraction, while RL dynamically adapts defense strategies to evolving adversarial vectors. Computational evaluation demonstrates the framework’s effectiveness, achieving 96.95% detection accuracy, precision of 96.9%, recall of 97%, and F-Score of 96.95%. The Defense Performance Index (DPI) reached 84.9%, validating model resilience, scalability, and balanced classification integrity. These findings highlight the broader implications of deploying transparent, adaptive, and generalizable safeguards for LLM based chatbot systems, advancing secure AI integration and mitigating systemic vulnerabilities in mission critical operations.

Victor Omoboye Oluwasegun, O. Falebita, Nabeela Temitayo Adebola et al. · 0 citations
Open access Aug 2026

You Are an Expert: RAG Injection and Guided Error Expert Activation for Jailbreaking Large Language Models

With the rapid development and widespread deployment of large language models (LLMs), the security and robustness of these models have emerged as critical research topics. Among various threats, jailbreak attacks, which aim to circumvent built‐in safety mechanisms, have garnered considerable attention as a key means of breaching model protections. However, existing jailbreak methods still face several limitations, such as excessive reliance on the model's internal capabilities, high attack costs and insufficiently comprehensive evaluation strategies. To address these challenges, we propose a novel jailbreak framework: YAE. This method enhances the model's dependency on external information by constructing a RAG‐based knowledge base containing harmful Q&A content. It also leverages Guide MoE, a routing‐inspired prompting strategy, to guide the model toward alternative reasoning trajectories through expert‐role prompting and domain‐specific perturbations, thereby inducing more deceptive responses. Furthermore, Adversarial Fine‐Tuning is employed to further optimize the performance of jailbreak attacks. We conduct extensive experiments under various settings, and the results demonstrate that YAE achieves state‐of‐the‐art performance in terms of both attack success rate (ASR) and efficiency, highlighting its strong overall effectiveness.

Shun Zhang, Ying Ding, Yanxu Mao · 0 citations
Preprint Jul 2026

On-Policy Distillation for LLM Safety: A Routing Approach to Template-Robust Realignment

Fine-tuning is the dominant paradigm for specializing large language models (LLMs), yet it exposes a critical vulnerability: malicious data providers can embed harmful behaviors into downstream corpora, creating models that retain professional skills while violating human values on demand. Existing safety-realignment defenses often fail in practice due to three key limitations: they frequently cause catastrophic forgetting of specialized skills; their effectiveness collapses when the defender cannot observe the attacker's prompt template; and successfully realigned models remain susceptible to re-jailbreaking via simple system prompt switches. To address these challenges, we propose Routing-based On-Policy Distillation (ROPD), a novel realignment framework that models the divergence between aligned and compromised output probability distributions rather than fitting specific prompt templates. We conduct extensive experiments comparing ROPD against four state-of-the-art baselines across three datasets and three base models with varying alignment strengths. Our results demonstrate that when baseline defenses face template mismatches, often accompanied by severe degradation in downstream task performance. In contrast, ROPD substantially mitigates template-mismatch risks, maintaining superior robustness in both defense effectiveness and capability preservation. While our analysis indicates ROPD is not entirely immune to template shifts, its performance degradation is negligible compared to existing methods, establishing a new standard for robust LLM realignment.

Yongjian Guo, Wanlun Ma, Lingyu Shen et al. · 0 citations
Conference Open access 2026

SafetyMem: Adaptive Jailbreak Defense via Dual-Component Safety Memory

Current defenses for Large Language Models (LLMs) often suffer from a “memory gap”: parameter-modifying methods are computationally rigid, while inference-time filters cannot retain or reuse defense knowledge across interactions. To address this, we propose Safet-yMem , a novel framework that secures LLMs through a dual-component safety memory sys-tem. SafetyMem consists of Semantic Safety Memory (SSM) , which consolidates diverse jailbreak attempts into a structured knowledge base of attack patterns, and Episodic Safety Memory (ESM) , which maintains an evolving set of procedural rules refined from historical detection failures. Unlike static defenses, Safe-tyMem allows the model to “remember” and adapt to emerging adversarial strategies without parameter retraining. To further enhance robustness, we introduce an adversarial memory expansion mechanism that proactively generates challenging variants to solidify these memories. Experiments on standard and stealthy jailbreak benchmarks show that SafetyMem substantially reduces attack success rates while preserving efficiency and interpretability, consistently outperforming state-of-the-art base-lines across multiple LLMs.

Hao Wang, Ziyi Ni, Huacan Wang et al. · 0 citations