Manuscript Offprint

arXiv:2610.02853

Bounded Reachability & Jailbreak Detection via Contraction-Constrained State Space Models

Omanshu Thapliyal

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Abstract

Safety heads are lightweight classifiers attached to pretrained language models for flagging harmful inputs before generation. Their empirical detection performance has been studied, but their formal robustness properties remain largely unexplored. We ask when a State Space Model (SSM)-based safety head can be certified to produce the same prediction for all inputs within a bounded embedding-space perturbation. We prove that the answer turns on a single condition: the l∞l_\infty norm of the state transition matrix must satisfy ∥A∥∞<1\|A\|_\infty < 1 (the contraction condition), which enables exact interval bound propagation (IBP) certification for linear time-invariant classifiers. When the contraction condition holds, the reachable output interval has bounded steady-state width and examples can be certified as robustly classified. When it fails, the interval grows exponentially with sequence length and certification is impossible at any practical perturbation radius. We enforce contraction with a hinge penalty and show on toxic comment data that certified fraction improves from 41% to 59%, with a sharp empirical phase transition at ∥A∥∞=1\|A\|_\infty = 1 matching the theory. Applying a contraction-regularized S4 head to jailbreak detection on JailbreakBench, we achieve a zero-shot transfer to AdvBench (DR=0.994) and HarmBench (DR=0.988). A logistic regression on mean-pooled Mamba-130M embeddings matches or exceeds the S4 head on every detection metric, confirming that harmful intent is already linearly separable in the embedding space. The S4 safety head's contribution is not superior discrimination but the formal certification that no probe-based approach provides.

The code is available at: https://github.com/omanshuthapliyal/contraction_constrained-safety-head.

1 Introduction

State-space models (SSMs) such as Mamba and Jamba (Gu & Dao (2024); Lieber et al. (2024)) offer computational advantages over Transformer-based architectures for long sequences. As SSM-based language models are deployed in safety-sensitive settings, a key question arises: how can we add safety mechanisms whose robustness is formally certifiable, rather than merely empirically evaluated? Current safety mechanisms fall into two categories. 1) Response-level judges examine model outputs for refusal or compliance language. These are brittle on base models without safety training, because such models do not produce structured refusal phrases. 2) Prompt-level classifiers operate on the input alone, but have rarely been subject to formal robustness analysis for sequence models.

Suppose an adversary perturbs an input to a safety classifier, then its output is perturbed as well. If we can bound how much the output perturbs over all inputs within some distance of the original, we can certify that the classification is stable under adversarial bounded

*Use footnote for providing further information about author (webpage, alternative address)—not for acknowledging funding agencies. Funding acknowledgements go at the end of the paper.

perturbations. Reachability Analysis for linear-time invariant (LTI) dynamical systems helps with these perturbation bounds as a property of the underlying dynamics. Reachable states for a (dynamical) system are all the possible output states the system can take, when input lies within a given (usually a bounded) set. For an LTI recurrence xt=Axt−1+Butx_t = Ax_{t-1} + Bu_t, the state at time tt is a linear function of all past inputs, so the reachable set of outputs is an interval that can be computed exactly. The key insight is that whether this interval stays bounded as tt grows depends entirely on the spectral radius of AA. If the largest row-sum norm ∥A∥∞<1\|A\|_\infty < 1, each state update contracts the current interval before the new input widens it, and the interval converges to a steady-state width. Conversely, if ∥A∥∞≥1\|A\|_\infty \geq 1, the input widening compounds each step and the interval grows unbounded. The contraction condition is therefore not a design choice; it is the exact threshold between certifiable and non-certifiable classifiers in this setting.

To this end, this paper makes two contributions. First, we make this connection precise for a toy LTI SSM classifier. We prove the contraction condition ( ∥A∥∞<1\|A\|_\infty < 1) is sufficient for the reachable output interval to be bounded by δ∥B∥∞/(1−∥A∥∞)\delta \|B\|_\infty / (1 - \|A\|_\infty), and necessary for this bound to be horizon-independent. A simple hinge penalty enforces contraction during training. We train the classifier on toxic comment data and measure how certified fraction varies with perturbation radius (50 log-spaced values), penalty strength (12 values), and sequence length (8 values).

Second, we apply a contraction-regularized two-layer S4 safety head to jailbreak detection on JailbreakBench (JBB; Chao et al. (2024)). The head operates on token embeddings from base Mamba-130M, classifies prompts without seeing any model response, achieves JDR=1.0 across six JBB attack families under a static threat model, and transfers zero-shot to AdvBench and HarmBench. A key negative finding is that logistic regression on the same mean-pooled embeddings achieves AUROC=1.0 on all three benchmarks, equaling or exceeding SSM-head on every detection metric. The Mamba-130M embedding space already separates harmful from benign prompts linearly and the SSM-head's recurrent architecture adds no discrimination advantage over this probe. Its distinctive contribution is formal certifiability: verifying a classification decision at a specified perturbation radius.

The formal results (Proposition 1) apply only to the toy LTI setting (see Appendix B). The JBB setting results are empirical claims on specific benchmarks under specific threat models (Section 4). We provide a detailed landscape of related work, main points of contributions, and current perceived limitations in Appendix A. Detailed experiments to validate the proposed methodology are presented in Appendix B, and the detailed JBB results and their discussions are present in Appendix C.

References (14)