CLASP: Defending Hybrid Large Language Models Against Hidden State Poisoning Attacks

Alexandre Le Mercier, Thomas Demeester, Chris Develder

Abstract

State space models (SSMs) like Mamba have gained significant traction as efficient alternatives to Transformers, achieving linear complexity while maintaining competitive performance. However, Hidden State Poisoning Attacks (HiSPAs), a recently discovered vulnerability that corrupts SSM memory through adversarial strings, pose a critical threat to these architectures and their hybrid variants. Framing the HiSPA mitigation task as a binary classification problem at the token level, we introduce the CLASP model to defend against this threat. CLASP exploits distinct patterns in Mamba's block output embeddings (BOEs) and uses an XGBoost classifier to identify malicious tokens with minimal computational overhead. We consider a realistic scenario in which both SSMs and HiSPAs are likely to be used: an LLM screening résumés to identify the best candidates for a role. Evaluated on a corpus of 2,483 résumés totaling 9.5M tokens with controlled injections, CLASP achieves 95.9% token-level F1 score and 99.3% document-level F1 score on malicious tokens detection. Crucially, the model generalizes to unseen attack patterns: under leave-one-out cross-validation, performance remains high (96.9% document-level F1), while under clustered cross-validation with structurally novel triggers, it maintains useful detection capability (91.6% average document-level F1). Operating independently of any downstream model, CLASP processes 1,032 tokens per second with under 4GB VRAM consumption, potentially making it suitable for real-world deployment as a lightweight front-line defense for SSM-based and hybrid architectures.

Introduction

As Large Language Models (LLMs) are increasingly integrated into automated workflows—such as screening thousands of résumés or summarizing legal documents—security becomes paramount. While most research focuses on Prompt Injection Attacks (PIAs) against Transformers, a new threat has emerged for the rising class of State Space Models (SSMs) and hybrid architectures like Jamba or Nemotron.

This threat is the Hidden State Poisoning Attack (HiSPA). Unlike a typical injection that attempts to trick the model into following a new command, a HiSPA uses adversarial strings to "poison" the model's recurrent memory (its hidden state). This can cause "partial amnesia," making the model forget previous context or steering it into an adversarial mode before a payload is even delivered. Because SSMs process information sequentially, this damage is often irreversible.

Comparison of vulnerability to Hidden State Poisoning Attacks (HiSPA) across different LLM architectures.

Methodology: The CLASP Defense

We introduce CLASP (Classification of Latent Activations for SSM Protection), a lightweight defense designed to intercept these attacks at the token level. Its core philosophy is that malicious tokens leave a "mathematical signature" inside the model that text-based filters might miss.

Feature Extraction and Fingerprinting

CLASP monitors Mamba’s Block Output Embeddings (BOEs). We discovered that HiSPA tokens produce sharp, identifiable "spikes" in the L2 norm of these embeddings. By analyzing these activations, we identified 13 specific "fingerprint" dimensions across Mamba's 64 blocks that consistently over-activate during an attack.

Classification Pipeline

Instead of a heavy neural network, CLASP utilizes an XGBoost classifier. It processes 409 numeric features per token, including statistics like mean, variance, and percentiles of the BOEs, alongside the specific fingerprint activations. Crucially, CLASP is designed to be time-invariant—it evaluates each token's internal state in isolation. This prevents the model from simply memorizing specific attack phrases and forces it to learn the underlying signal of state corruption.

The CLASP pipeline, showing prompt input, BOE extraction, and token-level classification alongside a visualization of L2 norm spikes.

Experimental Evaluation

To evaluate CLASP, we developed a new benchmark using a Résumé Corpus of 2,483 publicly available documents. Each résumé was processed in three variants: Clean (original), HiSPA (containing malicious triggers), and Benign (containing structurally similar but harmless natural language triggers).

Key Results

  • High Accuracy: CLASP achieved a 95.9% token-level F1 score and a near-perfect 99.3% document-level F1 score. If CLASP catches even one token of a multi-token attack, the entire document can be flagged.
  • Generalization: In "Leave-One-Out" tests on unseen attack patterns, it maintained a 96.9% document-level F1. Against structurally novel "zero-day" triggers, performance remained robust at 91.6%.
  • Efficiency: The system is remarkably lightweight, processing 1,032 tokens per second while consuming less than 4GB of VRAM, allowing it to run on modest hardware alongside the main LLM.

Conclusion

CLASP demonstrates that malicious tokens cause the model's internal architecture to "scream" in identifiable ways. By monitoring internal embeddings rather than just text content, CLASP provides a robust, model-independent front-line defense. Future work will explore the transferability of these mathematical signatures to other domains, such as source code or medical records, and investigate potential adaptive attacks designed to bypass BOE-based detection.

Summary updated

Abstract

State space models (SSMs) like Mamba have gained significant traction as efficient alternatives to Transformers, achieving linear complexity while maintaining competitive performance. However, Hidden State Poisoning Attacks (HiSPAs), a recently discovered vulnerability that corrupts SSM memory through adversarial strings, pose a critical threat to these architectures and their hybrid variants. Framing the HiSPA mitigation task as a binary classification problem at the token level, we introduce the CLASP model to defend against this threat. CLASP exploits distinct patterns in Mamba's block output embeddings (BOEs) and uses an XGBoost classifier to identify malicious tokens with minimal computational overhead. We consider a realistic scenario in which both SSMs and HiSPAs are likely to be used: an LLM screening résumés to identify the best candidates for a role. Evaluated on a corpus of 2,483 résumés totaling 9.5M tokens with controlled injections, CLASP achieves 95.9% token-level F1 score and 99.3% document-level F1 score on malicious tokens detection. Crucially, the model generalizes to unseen attack patterns: under leave-one-out cross-validation, performance remains high (96.9% document-level F1), while under clustered cross-validation with structurally novel triggers, it maintains useful detection capability (91.6% average document-level F1). Operating independently of any downstream model, CLASP processes 1,032 tokens per second with under 4GB VRAM consumption, potentially making it suitable for real-world deployment as a lightweight front-line defense for SSM-based and hybrid architectures. All code and detailed results are available at https://anonymous.4open.science/r/hispikes-91C0.
BibTeX
@misc{mercier2026clasp,
  author = {Alexandre Le Mercier and Thomas Demeester and Chris Develder},
  title = {{CLASP: Defending Hybrid Large Language Models Against Hidden State Poisoning Attacks}},
  year = {2026},
  eprint = {2603.12206},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2603.12206},
}
Figure