Manuscript Offprint

arXiv:2610.36258

SpecGuard: Detecting Multi-Turn LLM Jailbreaks via Specification-Based Runtime Monitoring

Junle Li, Siqi Chen, Jiakai Li, Bingzhuo Zhong

Junle Li, Siqi Chen, Jiakai Li, Bingzhuo Zhong ∗^{*}

Hong Kong University of Science and Technology (Guangzhou), Guangzhou, China

Email: {juliejunleli, bingzhuoz}@hkust-gz.edu.cn, {schen972, jli196}@connect.hkust-gz.edu.cn

Abstract—Multi-turn jailbreaks turn dialogue safety into a trace property: a violation may become identifiable only when user intent and assistant behavior are considered across multiple turns. Existing guard models largely classify individual messages or exchanges and return risk scores or labels, without executable safety semantics or a formally checkable decision trail. We present SpecGuard, a training-free, specification-driven framework for monitoring multi-turn LLM interactions. SpecGuard uses a fixed atomic-proposition contract to map natural-language observations into causally scoped, evidence-backed facts, and expresses forbidden interaction patterns as Linear Temporal Logic specifications. Each specification is compiled into a symbolic finite automaton that incrementally consumes the resulting dialogue trace. The same monitoring mechanism supports buffered runtime checking and retrospective auditing, while accepting 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 guard models while maintaining controlled false-positive rates. These results demonstrate a practical path from heuristic risk classification toward formally specified, verifiable, and auditable LLM safety monitoring, without learned detector parameters or access to the protected model.

I. INTRODUCTION

Large language models (LLMs) are increasingly deployed as interactive assistants in question answering, software development, agentic workflows, and human–AI collaboration. Despite substantial advances from alignment training and refusal mechanisms, attackers can still craft inputs that induce models to bypass their safety constraints and produce harmful content. Such attacks are commonly referred to as jailbreaks [1]. As LLMs increasingly serve real users, reliable and auditable monitoring of their interactions has become an important systems security problem.

This challenge is particularly acute in multi-turn interactions. Unlike single-turn attacks that issue a harmful request directly, attacks such as Crescendo [2] and X-Teaming [3] progressively establish an objective, adapt the attack strategy, and elicit assistance over a sequence of turns. When a turn is examined in isolation, neither the user request nor the model reply may provide sufficient evidence of a violation. The full safety semantics emerge only when the previously established objective, subsequent continuation, and substantive assistance from the model are considered together. Multi-turn jailbreak detection is therefore not merely a text-classification problem; it requires reasoning about behavioral relations in the interaction trace.

Existing defenses include training-time safety alignment, external guard models [4], [5], and inference-time interventions [6], [7]. However, most guard models classify individual prompts, responses, or turns and aggregate these local decisions at the conversation level. This approach poorly captures temporal behaviors such as objective continuation, gradual escalation, and refusal bypass. Moreover, neural classifiers typically output only a risk label or score, without identifying the satisfied safety conditions, the turns responsible for an alarm, or a reproducible audit trail.

Formal methods offer an alternative perspective. In safety-critical systems such as autonomous driving, robotics, and task planning, safety requirements are commonly expressed as executable temporal-logic specifications, and system traces are checked against those requirements through model checking or runtime verification [8], [9]. The value of this paradigm lies not only in producing a final verdict, but also in making safety conditions explicit objects that can be checked, reproduced, and maintained. This motivates our central question:

Can multi-turn jailbreak detection be formulated as specification monitoring over a dialogue trace, rather than as another black-box classifier over the entire conversation?

Applying this paradigm to natural language is nontrivial. The challenge is not merely to choose a temporal logic, but first to determine what the formal trace should represent. Program and physical states are typically described by predefined variables, whereas harmful objectives, execution requests, and conversational strategies must be abstracted from open-ended language. The semantic granularity of atomic propositions (APs) directly affects verification. If an AP already summarizes the final safety judgment, the specification merely reproduces an upstream classifier's conclusion and cannot express the concrete linguistic facts that led to it or support interpretable cross-turn composition. Conversely, if APs record only scattered surface cues, their meaning becomes unstable under paraphrase and contextual variation, making it difficult to distinguish substantive harmful assistance from benign discussion or an effective refusal. APs should therefore

Network and Distributed System Security (NDSS) Symposium 2027

22–26 March 2027, Seoul, Republic of Korea

ISBN 978-1-970672-09-1

https://dx.doi.org/10.14722/ndss.2027.[23|24]xxxx

www.ndss-symposium.org represent process-level facts that can be determined from a causal prefix, checked independently, and linked to their source evidence.

AP design is coupled with the strength of the specification constraints. Overly permissive specifications may treat the local co-occurrence of a high-risk topic and an execution-oriented expression as a violation, resulting in excessive false positives. Overly restrictive specifications may cover only a small set of fixed phrasings and miss realistic variants involving paraphrase, gradual escalation, or contextual continuation. Effective safety verification must balance coverage and discrimination by combining complementary evidence, relevant temporal relations, and necessary assistant-side behavior. The central design problem is thus not to define APs or temporal formulas independently, but to jointly determine the semantic boundaries of process-level facts, their causal activation conditions, and the scope of the specifications that constrain them.

To handle the difficulties above, we present SpecGuard, a specification-driven safety monitoring framework for multi-turn LLM interactions. Its core is an auditable AP contract that excludes result-shaped facts. We derive safety-relevant observations from security policies, known jailbreak behaviors, and development dialogues, and organize them into 15 canonical APs with explicit speaker roles, causal inputs, and semantic boundaries. These APs describe independently checkable process-level facts, such as whether the user establishes a harmful objective or issues an execution request, whether the assistant provides substantive content or procedural detail, and whether the response constitutes an effective refusal. Each activated AP retains its raw evidence provenance, making the conversion from natural language to symbolic traces in-spectable and replayable.

On top of this contract, SpecGuard encodes forbidden behaviors as ten Linear Temporal Logic (LTL) specifications: four same-turn specifications and six adjacent cross-turn specifications. Each specification requires substantive assistant-side evidence; a harmful request or attack signal alone cannot trigger a violation. SpecGuard compiles each specification into a symbolic deterministic finite automaton whose transition guards operate over canonical AP valuations. These automata consume the dialogue trace incrementally, converting the declarative safety requirements into executable finite-state monitors.

SpecGuard supports two execution modes using the same compiled automata. In runtime mode, a candidate response is held in a private buffer while the monitor advances the automata over the newly completed dialogue transaction. The response is released only if no specification reaches an accepting state. In audit mode, the system reconstructs an existing dialogue trace in causal order and records the first accepting transition for each matched specification. An accepting run produces a structured witness containing the triggered specification, relevant turns, matched APs, and their supporting evidence. The framework contains no learned detector parameters and requires neither access to the target LLM's weights, gradients, or internal activations nor modification of the protected model, allowing it to operate as an external monitor for any black-box LLM service.

To show the effectiveness of SpecGuard, we evaluate it on multiple multi-turn safety benchmarks and compare it with representative open-source guard models under identical inputs. SpecGuard achieves stronger detection performance across languages and attack trajectories while keeping false positives under control. Additional auditing shows that its alarms can be reproduced from the corresponding specification witnesses and that the runtime and audit paths agree when applied to the same dialogue under the shared semantics.

Our contributions are as follows:

• AP contract for conversational safety. We introduce an AP contract that connects natural-language analysis with formal verification by specifying which safety-relevant facts may enter a dialogue trace, when they may be causally observed, and how their source evidence is retained. The contract converts open-ended language into canonical propositions with explicit semantic boundaries, speaker attribution, and provenance. Beyond the resulting contract, the methodology itself is also transferable, providing a blueprint for constructing goal-oriented AP libraries.

• Data-grounded temporal safety specifications. We translate safety policies, known jailbreak behaviors, and interaction patterns observed in development dialogues into typed LTL specifications covering both same-turn violations and cross-turn behavioral evolution. This construction provides coverage across attack variants while explicitly controlling the scope of each constraint, making safety requirements executable, checkable, and maintainable. More broadly, the pipeline provides a transferable methodology for converting open-world knowledge into formal constraints for new monitoring scenarios.

• Finite-state monitoring framework. We compile typed LTL specifications into symbolic finite automata that incrementally consume causal dialogue traces. The resulting monitor supports both buffered runtime filtering and retrospective auditing, while accepting runs produce replayable witnesses that connect each verdict to the responsible specification, dialogue turns, and supporting AP evidence.

• Formal safety methodology for LLM jailbreak defense. We systematically show how runtime verification can be applied to black-box LLM safety defense by converting natural-language safety requirements into checkable specifications and coupling formal verdicts with auditable evidence. This provides a general path from heuristic moderation to specification-level checkability without modifying or retraining the protected model.

References (39)