Manuscript Offprint

arXiv:2608.25697

LMSM: LLM Security Framework Inspired by Linux Security Modules

XiuYu Zhang, Bonan Ruan, Junfeng Fang, An Zhang, Tat-Seng Chua, Zhenkai Liang

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

Abstract

Large language models (LLMs) are increasingly deployed with layered defenses, yet malicious prompts can still bypass them. Interpretability methods can expose model-internal signals along the generation path that could inform enforcement, but these signals are not security controls by themselves. Deployments that adapt them for safety typically couple each signal to its own calibration, policy logic, and intervention code, so each new artifact creates integration work instead of strengthening a shared defense. We present Language Model Security Modules (LMSM), a security framework that adapts the separation behind Linux Security Modules (LSM) to LLM serving. In LMSM, a selected security backend exposes calibrated evidence, a versioned policy evaluates active rules over trusted per-request context, and a separate gate authorizes buffered output release. This design separates mediation correctness from policy effectiveness, and it allows backend, rule, or schedule changes without rebuilding request handling or enforcement. Our prototype shows the separation working in practice: with Hugging Face Transformers and continuously batched vLLM, the same substrate hosts artifact-backed sparse autoencoder (SAE) and transcoder deployments and task-fitted dense probes, preserves request-specific decisions under scheduler churn, and selectively enforces and composes multiple rules per request. On Qwen3-4B, LMSM-Checkpoint reduces HarmBench attack success rate from 39.20% to 3.32%, with XSTest false refusals rising from 2.40% to 4.40%, while retaining 98.14% of the throughput of a matched serving path that performs no monitoring work at 32 active sequences. LMSM gives advances in interpretability and model-internal analysis a common path to runtime enforcement.

1 Introduction

Large language models (LLMs) are no longer predictors that answer one prompt and disappear. In a deployed service, a request is assembled from system instructions, conversation history, retrieved documents, tool outputs, and application-supplied content before it reaches the model. After generation, the response may be buffered, filtered, logged, transformed, or passed to another tool before it becomes externally visible. The model is therefore one component in a longer, stateful path.

The same path that assembles and delivers a response is also where familiar security failures arise. A jailbreak may persuade the model to ignore its refusal behavior, an obfuscated request may slip past a text filter, and a retrieved document or tool output may inject adversarial instructions into an otherwise benign interaction [5, 34, 42]. Researchers of LLMs respond with several layers of defense: alignment shapes the model's default behavior, prompt controls constrain its context, and external guards inspect its inputs and outputs [13, 25, 34, 39]. These layers reduce risk, but they do not provide a trusted path from model-internal evidence to policy enforcement before output release.

The deployment path matters because a defense’s position determines what it can observe and change. Alignment acts through model weights, prompt controls share the same context channel as untrusted content, and external guards see text at the system boundary. Interpretability methods such as sparse autoencoders (SAEs) and transcoders expose structure in model activations, while probes, activation directions, and related monitors can connect internal state to a deployment target [3, 7, 12, 17]. Once adapted for safety, both can inform a decision before releasing buffered output. This early access is useful, but it does not by itself amount to a deployable security control. Turning that evidence into a defense usually binds a particular artifact or monitor to its own calibration procedure, policy logic, and intervention [17, 38, 41]. When the artifact, target, or action changes, the integration often changes with it. Each new artifact or monitor tends to produce another guard rather than strengthen a common runtime.

Systems security has faced a similar separation problem. The reference-monitor principle requires security-relevant operations to cross an authoritative mediator before protected state changes [1, 30]. Linux Security Modules (LSM) turned

Figure

Figure 1: From standalone model-internal guards to the shared enforcement substrate at the core of LMSM. (a) When each interpretability backend is deployed on its own, it brings its own decision and action code, so adding a backend recreates the guard stack. (b) LMSM instead places backend alternatives behind a common contract, resolves active rules through a versioned policy, and applies per-request decisions through a separate enforcement gate. New backends require binding and calibration, plus fitting when needed, without redesigning request handling or enforcement.

that principle into an extensible interface: the kernel provides stable mediation points and trusted context, pluggable modules supply policy decisions, and the kernel applies the result [37]. Its lasting contribution is not any one policy, such as SELinux or AppArmor [2,21], but the separation that allows policies to evolve without rebuilding the mediation path. We borrow this separation, though not the kernel’s isolation guarantees.

We present Language Model Security Modules (LMSM), an LSM-inspired security framework built around a reusable runtime enforcement substrate. In LMSM, interpretability artifacts and other model-internal analysis methods are adapted into security backends, rather than treated as complete defenses in their own right. Backends expose calibrated evidence. A versioned operator policy selects active rules and resolves their triggers, while a separate enforcement gate applies the resulting state change. The same mediation path supports different backend bindings and policies across deployments without changing its action vocabulary or enforcement gate.

This structure lets an operator add deployment-specific requirements to an aligned model without changing its weights. It also leaves the runtime independent of how a backend was obtained. With artifact-backed provisioning, the operator binds and calibrates a released representation, such as SAE [12] or transcoder [7]. With task-fitted provisioning, the operator learns or substantially adapts a backend for the deployment target. The distinction concerns provenance, not representation type: either path may use sparse or dense representations.

A telehealth service illustrates how these pieces fit together. The service may deploy an already aligned model but must still keep it from issuing patient-specific dosage instructions, a restriction set by its jurisdiction rather than by the model provider. If a released SAE or transcoder exposes a representation aligned with this target, the operator binds it and calibrates a dosage-advice rule; otherwise, the operator fits a backend from in-domain examples. The rule then enters the versioned library and is activated in the service's policy bundle. During generation, the backend exposes calibrated evidence, the policy determines whether and when the rule fires, and the enforcement gate replaces a prohibited buffered response with the configured reply. If a better artifact becomes available later, the operator updates the binding and affected rule conditions without changing the evaluator interface, request handling, or enforcement path.

We implement LMSM with artifact-backed SAE and transcoder deployments, task-fitted dense-probe policies, and a continuously batched vLLM runtime [19]. The evaluation asks whether the separation survives the conditions that make serving integration difficult: scheduler churn, heterogeneous internal representations, multiple active rules, and policies that act at different times during decoding. All 32 duplicate request pairs preserve their action, selected category, intervention step, and complete vector of per-rule threshold-crossing outcomes as the scheduler moves and reuses batch slots. Changing the backend binding does not require changes to request handling, the evaluator interface, or enforcement. On Qwen3-4B, the task-fitted policies reduce matched harmful-output rates.

by 82.5%–91.5%. Relative to the same serving path with monitoring disabled, the Checkpoint policy retains 98.14% throughput at width 32 and, in a separate composition campaign, 96.89% with all 15 rules active.

Our contribution can be summarized as follows:

  • We formulate the use of model-internal evidence for safety as a runtime-mediation problem, separating the integrity of the release path from the effectiveness of installed evidence and rules.

  • We design LMSM around stable interfaces among a selected backend, versioned rules over request-keyed state, and a gate that authorizes buffered output release. Backend, rule-set, and schedule changes remain local.

  • We implement LMSM for Hugging Face Transformers and continuously batched vLLM with SAE, transcoder, and dense-probe backends. We evaluate scheduler churn, backend substitution, rule composition, temporal behavior, policy effectiveness, and serving cost. At width 32, LMSM-Checkpoint reduces HarmBench attack success rate from 39.20% to 3.32% while retaining 98.14% of the throughput measured on the same serving path with monitoring disabled.

Together, these results show how improvements in model-internal analysis can strengthen a deployed security framework without requiring a new serving and enforcement stack for each backend.

References (38)