SpecGuard: Detecting Multi-Turn LLM Jailbreaks via Specification-Based Runtime MonitoringSpecGuard: Detecting Multi-Turn LLM Jailbreaks via Specification-Based Runtime Monitoring
The authors propose SpecGuard, which monitors multi-turn jailbreaks with LTLf specifications and finite automata, and exceeds four open-source guardrail models in F1 and AUC on three benchmarks.
The attacker is an adaptive adversary who interacts with an aligned LLM through natural language dialogue, controls user messages and observes replies, and can make single-turn requests or multi-turn jailbreaks. The defender is an external, causal monitor that can only see the current dialogue transcript, has no access to the target model's weights, gradients, or activations, and does not modify the target model.
- Multi-turn jailbreaks distribute malicious intent across multiple seemingly harmless turns; existing guardrail models mostly classify a single message or single turn, outputting only a risk score or label, and lack executable safety semantics and auditable decision traces.
- SpecGuard uses a fixed contract of 15 atomic propositions (APs) to extract dialogues into symbolic trajectories with evidence provenance, writes prohibited behaviors as 10 LTLf specifications and compiles them into finite automata for turn-by-turn monitoring; it has no learned parameters, requires no access to the protected model, and supports both runtime interception and post-hoc auditing modes.
- On a total of 10,075 dialogues across SafeDialBench-ZH/EN and SafeMTData, the authors report that SpecGuard has the highest AUC, F1, recall and BA, with F1 higher than the strongest baseline on each benchmark by 0.222, 0.290 and 0.222 respectively; all 1,652 witnesses from 5,000 random trajectories were successfully replayed.
- The authors state that the formal guarantees hold only at the boundary of symbolic trajectories and do not assume error-free natural-language AP extraction; the conclusion proposes two future directions: extending to multimodal interaction and witness-based response regeneration. The evaluation covers three English/Chinese benchmarks and four open-source guardrail baselines, and does not include experiments on adaptive evasion attacks.
- Benchmarks
- SafeDialBench-ZHSafeDialBench-ENSafeMTData
- Metrics
- AUCF1FPRRecallBA
Researchers propose SpecGuard, a training-free, specification-based framework for monitoring multi-turn LLM interactions to detect multi-turn jailbreaks. The framework uses fixed atomic-proposition contracts to map natural-language observations into facts with causal scope and evidential support, expresses prohibited interaction patterns as linear temporal logic (LTL) specifications, and compiles them into symbolic finite automata that incrementally consume dialogue traces. The same monitoring mechanism supports buffered runtime checking and retrospective auditing; accepted runs produce replayable witnesses that identify the triggered specification, supporting facts, and relevant dialogue turns. Experiments on multi-turn safety benchmarks show that SpecGuard consistently outperforms representative open-source guardrail models while maintaining a controllable false-positive rate, and without requiring learned detector parameters or access to the protected model.
Related events and news
1 events · 1 news mentions
News that mentions this paper
周报:预训练投毒可植入智能体后门
- 公众号 大模型安全研究cites the paper's id or link大模型安全周报:首次证明预训练投毒可植入远程代码执行后门,技能供应链成为攻防主战场
SpecGuard: Detecting Multi-Turn LLM Jailbreaks via Specification-Based Runtime Monitoring(https://arxiv.org/abs/2610.36258)
Paper analysis
What problem does this paper attempt to solve?
Shift multi-turn jailbreak detection from black-box classification to normative monitoring of dialogue trajectories, requiring executable semantics and auditable determinations.
Core problem: A multi-turn jailbreak violation can only be identified when user intent and assistant behavior are examined jointly across turns, whereas most existing guardrail models classify a single message or a single turn, lacking executable safety semantics and formally checkable decision traces.
- Problem setting: The authors point out that multi-turn attacks such as Crescendo and X-Teaming spread a malicious goal across a sequence of individually seemingly harmless turns, and isolated single-turn checks cannot identify temporal behaviors such as goal establishment, gradual escalation, and refusal circumvention.
- Shortcomings of existing methods: The authors argue that most guardrail models classify a single prompt, response or turn and then aggregate at the session level, outputting only a risk label or score; they neither indicate which safety condition was triggered and which turn is responsible, nor provide a reproducible audit trace.
- Core observation: The authors draw on the practice of safety-critical systems—writing safety requirements as executable temporal logic specifications and performing runtime verification on system trajectories; the key difficulty is what formal trajectory to abstract open-ended natural language into: AP granularity that is too coarse degenerates into the conclusions of upstream classifiers, while too fine is unstable under paraphrasing and context changes.
- Proposed in the paper: SpecGuard, a training-free, specification-driven framework for monitoring multi-turn interactions: a fixed AP contract maps natural-language observations to facts with evidence provenance, prohibited patterns are written as LTLf specifications and compiled into symbolic finite automata, supporting runtime buffered checking and post-hoc auditing, and producing replayable witnesses on a hit.
- Threat model (Section III-A):
- Attacker: an adaptive adversary interacting with an aligned LLM through natural-language dialogue, whose goal is to induce the model to provide unsafe assistance; it controls user messages and observes model responses, and may issue single-turn requests or spread the goal across multiple turns.
- Defender: an external, causal monitor that, after each turn, sees only the currently available transcript and checks the trajectory against fixed safety specifications.
- Knowledge and capability boundary: The defender has no access to the target model's weights, gradients or activations, and does not modify or retrain the target model; the monitoring interface depends only on dialogue text and is independent of model architecture.
- Victim system: any black-box LLM service, with the monitor running as an external component.
What related research exists?
Related work is divided into three groups: multi-turn jailbreaks and defenses, formal verification, and natural language to specification; the authors state that this paper fills the gap at the formal specification layer for multi-turn violations.
Multi-turn jailbreak attacks and defenses
- Multi-turn attacks: Crescendo, Many-shot Jailbreaking, ActorAttack, and X-Teaming erode a model's refusal behavior through a sequence of individually harmless turns, so that malicious intent is distributed across the entire dialogue trajectory and does not exist in any single message.
- Single-turn guardrail models: From Llama Guard to recent bilingual variants (the paper names ShieldGemma, WildGuard, BingoGuard, and GuardReasoner as examples), these classify a single prompt or response; the authors note that even when given the full history as input, their decisions do not reference the temporal structure across turns.
- Multi-turn defenses: SafeDream accumulates learned safety estimates across turns, THRD fuses single-turn risk with historical signals using a training-free evaluator, G-Guard models cross-turn intent aggregation on a graph, and TurnGate locates the earliest turn at which harmful capability closes. The authors argue that these works establish the necessity of cross-turn temporal reasoning, but the violation criterion remains implicit—residing in fine-tuned weights, reviewer prompts, or scoring heuristics, rather than being an object that can be independently checked, composed, and verified.
Formal specifications and runtime verification
- Safety-critical systems: In autonomous driving, robot control, and multi-agent planning, temporal logic and runtime verification are used to rule out violations during execution.
- Verification in LLM systems: VeriPlan integrates model checking into the planning process, ShieldAgent constrains agent actions with verifiable rules extracted from policy documents, and R2-Guard performs probabilistic logical reasoning over the safety category of a single input within a guardrail. The authors note that in this line of work, what is monitored has always been the action layer of robots, planners, or agents; the conversational behavior of the LLM itself has never been the object of runtime verification.
Natural language to formal specifications
- Specification generation: nl2spec, NL2TL, and others translate natural language requirements and safety rules into machine-checkable formal specifications, with attention to the semantic fidelity and safety of the generated formulas. The authors note that this line of work assumes the rules already exist in traffic regulations, requirements documents, or physical constraints, whereas conversational safety does not satisfy this premise—which dialogue patterns constitute a jailbreak has never been written down as rules.
- Attack and policy taxonomies: Shen et al. characterize in-the-wild jailbreak prompts at scale, Liu et al. distill attack patterns in prompt engineering, and taxonomies derived from platform regulations organize safety risk categories. The authors argue that these taxonomies are descriptive, are themselves neither executable nor checkable, and have no formal connection to a running conversation.
Baselines and benchmarks
- Comparison baselines: Four open-source guardrail models ShieldGemma-2B, WildGuard-7B, BingoGuard-8B, and GuardReasoner-8B, which classify turn by turn under identical inputs and aggregate to the session level; Table IV additionally transcribes the values reported in the original sources for R2-Guard, SelfDefend, Circuit Breaker, X-Boundary, TARS, and SafeDream as references.
- Evaluation benchmarks: Three multi-turn safety benchmarks: SafeDialBench-ZH, SafeDialBench-EN, and SafeMTData.
Authors' positioning: Existing defenses are executable but implicit, and existing taxonomies are explicit but not executable; the authors state that, to their knowledge, no formal specification set for multi-turn jailbreaks existed previously, and SpecGuard's rule base is the first systematic attempt to fill this gap.
How does the paper address this problem?
A contract with a fixed set of 15 APs extracts symbolic dialogue trajectories, and 10 LTLf specifications are compiled into finite automata for turn-by-turn monitoring, producing replayable witnesses on a hit.
Overall approach: SpecGuard separates fact abstraction from violation determination—an upstream component extracts the dialogue into a normalized trajectory of atomic propositions (APs), and the final decision is determined entirely by matching that trajectory against temporal specifications; the framework has no learned detector parameters and requires no access to the protected model.
Problem formalization
- Dialogue and trajectory: A dialogue D = (u0, r0, …, uT, rT), with one user message ut and response rt per turn; the full set of APs is partitioned into three disjoint families: user-side AU, response-side AR, and history-side AD; the values At at turn t are computed by a causal extractor from the prefix, and user-side propositions do not depend on subsequent responses.
- Specifications and alarms: The specification set Φ = {ϕ1, …, ϕm} consists of LTLf formulas, and an alarm is defined as
\mathrm{Alarm}(D) = \mathbf{1}[\exists \phi \in \Phi : w(D) \models_f \phi], i.e., triggered when the trajectory satisfies any specification; each matched pattern requires multiple observations, including substantive assistant-side evidence, and user behavior alone is insufficient to constitute a violation. - LTLf fragment: All specifications stay within the {F, X} fragment, with F locating prohibited patterns and X constraining the order of adjacent turns; history dependence is represented by history APs that retain provenance.
AP contract (15 propositions)
- Sources: The specifications and AP contract come from three types of sources—existing safety policies and content risk taxonomies, temporal relations identified by multi-turn jailbreak research (request continuation, intent escalation, goal reference, refusal circumvention), and jailbreak/refusal/benign examples from WildChat-1M, MTID-train and WildGuardMix as development data; the authors emphasize that APs are not induced directly from endpoint labels.
- Selection criteria: A candidate factor must be causally instantiable from the observed prefix, represent an observation rather than a judgment, be able to distinguish at least one pair of semantically similar dialogues with different safety implications, and be reusable across specifications while retaining evidence.
- Vocabulary: 15 typed APs (Table I)—2 history/context factors (e.g., c_harm_context, d_objective_source), 6 user-side factors (e.g., u_harmful_objective, u_execution_request, u_evasion_tactic, u_continuation), and 7 assistant-side factors (e.g., a_substantive_content, a_procedural_detail, a_effective_refusal); the contract excludes outcome-shaped predicates (such as endpoint propositions like a_harmful_delivery that directly denote "harmful delivery").
Specification library (10 constraints)
- Common assistant-side condition:
Q_A \triangleq A_s \wedge (A_p \vee A_m \vee A_e \vee A_t) \wedge \neg A_r, i.e., the response contains substantive content, carries at least one kind of policy-relevant detail, and is not an effective refusal; QA is only an abbreviation, not a new AP. - Constraint composition: 4 same-turn constraints (offset (0,0)) and 6 adjacent-turn constraints (offset (0,1)), covering same-turn procedural assistance, context specificity, enabling/directive content, evasive assistance, and cross-turn continuation, escalation, refusal circumvention, escalation after partial assistance, goal-reference recovery, and assistance in continuous harmful context (Table XI).
- Freezing: Before evaluation, causal observability, speaker type, refusal veto and cross-turn ordering were validated on harmful, benign and refusal examples, and it was verified that injecting the excluded endpoint predicates does not change the trajectory or the decision; the AP vocabulary, projection and constraint library were then jointly frozen.
AP activation pipeline
- Three stages: Evidence grounding (52 deterministic text matchers, 9 evidence families, plus 6 bounded relation matchers, outputting evidence records with provenance rather than labels) → relation composition (organizing evidence into typed request frames, distinguishing direct and bound relations) → contract guard and AP projection (after fixed-condition filtering, activating canonical APs by predefined composition, retaining Provt(a) provenance).
- Causality: User-side facts are instantiated from the pre-response prefix, and response-side and dialogue-side facts may use the post-response prefix; once materialized, the trajectory cannot be modified by subsequent messages, and history APs do not propagate backward.
Compilation and two execution modes
- Automata: Same-turn specifications F(B) compile into two-state automata, and adjacent-turn specifications F(H ∧ XG) compile into three-state automata, with accepting states absorbing; compilation is performed once when the specification library is loaded, and transitions are represented symbolically as predicates over AP values.
- Runtime mode: A candidate response is first placed in a private buffer; the monitor evaluates on a temporary copy of the monitoring state, and the response is committed and released only if no automaton enters an accepting state; otherwise it is withheld and handed to the deployment policy (block, replace, or human review); each turn performs one constant-width transition per specification, with O(|Φ|) time and state.
- Audit mode: A completed dialogue is replayed in its original order, the earliest accepting turn for each specification is recorded, and all matched specifications and witnesses are returned; a witness contains the triggered specification, the relevant turns, the matched APs and their original evidence, the specification fingerprint and the trajectory digest, and is replayed and verified before the decision, with witnesses that cannot be reproduced rejected.
- Success determination: The monitor outputs a Boolean decision; AUC is computed using a deterministic, label-free specification-completion score (the mean over legal temporal alignments of the proportion of satisfied clauses, then the maximum over alignments and specifications), and the score is 1 if and only if the formal decision is a violation.
What experiments did the paper conduct?
F1/AUC/recall/BA are all highest on the three multi-turn benchmarks, all witnesses are replayable, and cross-turn specifications provide the main gain under a fixed AP trajectory.
Experimental setup
- Subjects: SpecGuard (no model parameters) and four open-source guardrail baselines ShieldGemma-2B, WildGuard-7B, BingoGuard-8B, and GuardReasoner-8B; the baselines classify each turn independently via a stateless interface, and any flagged turn produces a session-level alert, using fixed official checkpoints, native inference templates, and sampling disabled.
- Datasets (Table II): SafeDialBench-ZH (3,602 dialogues, 16,628 turns, positive/negative 1,981/1,621), SafeDialBench-EN (3,639 dialogues, 17,913 turns, 2,005/1,634), SafeMTData (2,834 dialogues, 14,392 turns, 1,680/1,154); totaling 10,075 dialogues and 48,933 turns. SafeDialBench uses assistant-side violations as positives, and SafeMTData labels complete ActorAttack trajectories (including attacks that end in a refusal).
- Metrics: F1 is the primary metric; FPR, recall, BA = (Recall + (1 − FPR)) / 2, and AUC are also reported; the evaluation unit is the complete dialogue, and labels are not mixed across datasets.
- Protocol: All methods receive exactly the same ordered user–assistant exchanges; SpecGuard uses the same 15-proposition contract, 10 constraints, and frozen decision rules across the three benchmarks, with no benchmark-specific threshold tuning; the external method values in Table IV are transcribed from their respective papers and serve only as references, not as same-input comparisons.
- Repetition and auditing: The integrity audit is performed on 5,000 random trajectories of length 1–8; runtime is measured on an Apple M4 CPU with 4 workers, processing each dialogue in SafeDialBench-EN once.
Main results
Session-level detection performance (from Table III; best values bolded as marked in the original source):
Swipe horizontally to read the table
Method ZH AUC ZH F1 ZH FPR EN AUC EN F1 EN FPR MT AUC MT F1 MT FPR WildGuard-7B 0.865 0.449 0.012 0.831 0.652 0.009 0.444 0.694 0.022 GuardReasoner-8B 0.851 0.759 0.030 0.730 0.638 0.018 0.342 0.717 0.065 BingoGuard-8B 0.712 0.363 0.012 0.636 0.271 0.018 0.445 0.101 0.076 ShieldGemma-2B 0.868 0.160 0.007 0.901 0.173 0.002 0.816 0.235 0.017 SpecGuard 0.984 0.981 0.028 0.943 0.942 0.107 0.967 0.939 0.036 - Authors' interpretation: SpecGuard has the highest AUC, F1, and recall on all three benchmarks, with F1 higher than the strongest baseline on each benchmark by 0.222 (ZH), 0.290 (EN), and 0.222 (MTData); BA is also highest (0.978 / 0.931 / 0.936).
- FPR exception: SpecGuard's FPR is not the lowest—the baselines with the lowest FPR detect only 8.7–13.5% of positive dialogues, whereas SpecGuard recalls 90.7–98.4%; SafeDialBench-EN is its most recall-oriented operating point (recall 96.9%, FPR 10.7%), and the authors state that the higher FPR reflects the frozen operating point choice rather than insufficient discriminative ability.
- Reference comparison (Table IV, transcribed values): The authors state that SpecGuard achieves the strongest AUC, F1, and recall shown on SafeDialBench, with FPR comparable to SafeDream; on SafeMTData, both F1 and FPR are better than the transcribed reference operating points.
Contribution of cross-turn specifications
- Setup: On a fixed AP trajectory, three rule masks are compared—only the 4 same-turn constraints (Same-turn), only the 6 cross-turn constraints (Temporal), and all 10 (Full), per Figure 4.
- Results: Adding cross-turn specifications raises F1 from 0.975 to 0.981 (ZH), 0.899 to 0.942 (EN), and 0.877 to 0.939 (MTData); it detects 25, 172, and 184 additional true positives respectively, with only 1, 14, and 5 additional false positives; cross-turn specifications alone also reach F1 of 0.939, 0.930, and 0.859.
- Authors' interpretation: The two rule types are complementary; since the AP trajectory is fixed, the gain comes from temporal composition rather than proposition extraction.
Faithfulness and auditability
- Decision-path replay (Table V): On 5,000 random trajectories, all 1,652 witnesses produced by 995 alerting trajectories replay successfully; on all 10,075 dialogues, the completeness score of 1 has zero inconsistency with the boolean decision.
- No decision shortcuts: After injecting each excluded endpoint AP into random trajectories and re-evaluating, the specification projection removes it, and the decision and trajectory summary show zero change on the 5K trajectories; all 7 regression tests pass.
- Authors' interpretation: These checks form a closed audit path from raw evidence to specification APs, to ordered witnesses, and to the decision conclusion; Table V establishes exact faithfulness between the symbolic decision and the derived evidence, while errors in the natural language extraction stage are evaluated separately.
Trigger timing and runtime
- Trigger timing (Figure 5): The earliest witness-completion turn is normalized as p = (t_trigger + 1)/T; the authors state that the full monitor detects more positives before the dialogue midpoint and maintains its advantage through the last turn, so temporal evidence improves both early detection and final recall.
- Length stratification (Table VI): F1 does not degrade in the ≥5-turn stratum—ZH 0.976 for 3–4 turns (n=1,480) and 0.984 for ≥5 turns (n=2,122); EN 0.922 (n=481) and 0.945 (n=3,158); MTData 0.934 (n=659) and 0.953 (n=2,023); dialogues with fewer than 3 turns (SafeMTData, n=152) are omitted.
- Runtime (Table VII): SafeDialBench-EN, all 17,913 turns, takes 246.8 seconds end to end, 72.6 turns/second, amortized 67.8 ms per dialogue and 13.8 ms per turn, including evidence generation and completeness scoring, using CPU only.
Other ablations and analyses
- There are no other separate ablation subsections; the cross-turn contribution, length stratification, and integrity checks are the main analyses (Figure 4, Table VI, Table V).
What are some points that can be further explored?
The authors state that the formal guarantees do not cover natural-language extraction errors, and propose two directions: multimodal extension and witness-based response regeneration.
Limitations and future directions noted by the authors
- Guarantee boundary (Section V-C and Appendix E): The authors state explicitly that formal properties such as correctness, prefix consistency, and runtime–audit equivalence hold only at the boundary of symbolic trajectories, and "do not assume error-free natural-language AP activation", i.e., correct extraction of natural-language facts is not guaranteed; missing or falsely activated APs need to be evaluated separately.
- Adaptive evasion risk (Ethics Considerations): The authors acknowledge that the released specifications may provide information for adaptive evasion, but consider that explicit auditable rules mainly benefit defenders and can be revised as attacks evolve.
- Future direction one (Section VI): Extend to multimodal interaction, grounding APs in unified temporal trajectories of text, image, audio and video.
- Future direction two (Section VI): Response regeneration based on replayable witnesses—when a violation is detected, use the matched constraints and evidence to locate what needs modification, regenerate, and then check again; the authors state this can build on counterexample-guided specification-revision-and-regeneration work.
Experimental coverage
- Benchmarks and scale: Evaluation covers three benchmarks, SafeDialBench-ZH, SafeDialBench-EN and SafeMTData, totaling 10,075 dialogues and 48,933 turns, in Chinese and English (Table II).
- Baselines: Baselines compared on the same inputs are four open-source guardrail models (ShieldGemma-2B, WildGuard-7B, BingoGuard-8B, GuardReasoner-8B); the values for R2-Guard, SelfDefend, Circuit Breaker, X-Boundary, TARS and SafeDream in Table IV are transcribed from their respective papers, and the authors state explicitly that these use their original evaluation protocols and serve only as reference.
- Positive-example semantics: SafeDialBench treats response-side violations as positive examples, and SafeMTData treats complete ActorAttack trajectories as positive examples (including attacks that end in a refusal); the labels of the three are not mixed.
- Audit and performance measurement: The integrity audit is conducted on 5,000 random trajectories of length 1–8; runtime is measured only on SafeDialBench-EN, once, on an Apple M4 CPU with 4 workers (Table VII).
- Not reported in the paper: Detection experiments against adaptive attackers evading the published specifications; the accuracy of the AP extraction stage itself against human-annotated ground truth; variance or confidence intervals across repeated runs.
Summarize the main content of the paper
SpecGuard formulates multi-turn jailbreak detection as an LTLf specification monitoring problem, achieving the highest F1 on the three benchmarks and decisions that support replayable auditing.
A paper on multi-turn jailbreak detection: the authors treat violations as temporal properties over dialogue trajectories and propose SpecGuard, a training-free, specification-driven monitoring framework that requires no access to the protected model.
- Problem addressed: Multi-turn attacks spread malicious intent across individually seemingly harmless turns; existing guardrail models classify message by message and give only risk scores, lacking executable semantics and auditable traces.
- Method highlights: A fixed 15-proposition AP contract causally extracts the dialogue into a symbolic trajectory with evidence provenance (52 deterministic matchers + contract guards, excluding outcome-shaped predicates); 10 LTLf specifications (4 same-turn, 6 adjacent-turn, all requiring substantive assistant-side evidence) are compiled into symbolic finite automata for turn-by-turn monitoring; the same automata support runtime buffered interception and post-hoc auditing, and a hit produces a replayable witness containing the specification fingerprint and trajectory digest.
- Main results: On SafeDialBench-ZH/EN and SafeMTData (10,075 dialogues in total), the authors report that SpecGuard has the highest AUC, F1, recall and BA across the three benchmarks, with F1 reaching 0.981, 0.942 and 0.939 respectively, higher than the strongest baseline on each benchmark by 0.222, 0.290 and 0.222 (Table III); FPR is not the lowest, at 0.107 on SafeDialBench-EN.
- Source of gains: Under the fixed AP trajectory, adding cross-turn specifications raises F1 from 0.975/0.899/0.877 to 0.981/0.942/0.939, with only 1/14/5 additional false positives (Figure 4).
- Auditability and efficiency: All 1,652 witnesses from 5,000 random trajectories were successfully replayed, and injecting the excluded endpoint predicates does not change the decision (Table V); end-to-end CPU throughput on SafeDialBench-EN is 72.6 turns/second (Table VII).
- Authors' conclusion: The authors state that this offers a path from heuristic risk classification toward formal, verifiable and auditable LLM safety monitoring; the formal guarantees are limited to the boundary of symbolic trajectories and do not cover natural-language extraction errors, and future directions include multimodal extension and witness-based response regeneration.