Scientific Reports

Adversarial prompt detection via contrastive dual-encoder transformer for zero-day jailbreak defense based on AdverSentinel-LLM model

Ghalib H. Alshammri

Key points

From the paper's conclusion
  • We additionally incorporate a Dynamic Threat Memory Bank (DTMB) with prototype pruning and rejuvenation to prevent stagnation, and an Anomaly-Aware Gating Mechanism (AAGM) for context-sensitive detection threshold modulation.

Abstract

Large Language Models (LLMs) have become core elements of current artificial intelligence applications yet are highly susceptible to adversarial prompt attacks such as jailbreaks that compromise safety alignment. Current defense mechanisms rely predominantly on fixed rule-based filters or single-encoder classifiers with limited generalizability to new, zero-day jailbreak signatures. This paper presents AdverSentinel-LLM, a novel adversarial prompt detector based on a Contrastive Dual-Encoder Transformer (CDET) architecture trained to identify malicious prompts in real time, including zero-day jailbreak attacks. The CDET architecture maintains two independent representation spaces—one encoding prompt semantics and one encoding structured threat patterns—trained jointly under a supervised contrastive objective that explicitly pushes adversarial embeddings away from benign clusters, enabling zero-day generalization to unseen attack vectors via contrastive disentanglement. The framework comprises two parallel transformer encoders: a Prompt Semantic Encoder (PSE) that learns deep contextual representations of input prompts and a Threat Pattern Encoder (TPE) that learns discriminative representations of known adversarial attack patterns. A supervised contrastive learning objective encourages separation between adversarial and benign embeddings, enabling zero-day generalization to unseen attack vectors. We additionally incorporate a Dynamic Threat Memory Bank (DTMB) with prototype pruning and rejuvenation to prevent stagnation, and an Anomaly-Aware Gating Mechanism (AAGM) for context-sensitive detection threshold modulation. Extensive experiments on AdvBench, JailbreakBench, ToxicChat, and PromptSafety-Bench demonstrate state-of-the-art performance with an F1-score of 0.967, detection accuracy of 97.3%, and a zero-day detection rate of 94.8%, with the contribution of every architectural element verified by ablation studies and preliminary evidence of cross-model transferability demonstrated across adversarial prompt distributions independently curated against GPT-4, LLaMA-3, Claude-3, and Gemini-Pro backends; a controlled matched-prompt evaluation is deferred to future work.

Read the paper

Discussion

Science Skim's AI key points, plus readers' public thoughts

Readers' thoughts

No reader thoughts yet.

Related papers