Manuscript Offprint

arXiv:2610.02432

Evaluating and Improving the Robustness of Large Language Models to Input Sequence Variations

Narek Maloyan

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

Abstract

Large language models (LLMs) embedded in production systems face prompt injections, trojans, and manipulation of automatic quality metrics. This thesis develops a set of models, methods, and algorithms for evaluating and improving the robustness of LLMs to adversarial input sequence variations: prompt injection, trojans (backdoor attacks), and attacks on agentic LLM systems. We propose Rstab(f)R_{stab}(f), a formal metric of generative robustness based on bounded divergence measures, in particular the Jensen–Shannon divergence, between per-step output distributions under small input perturbations. For localized attacks, we prove that the vulnerability of a deterministic decision operator h is bounded by its non-robustness: V(h)≤1−Rclass(h)V(h) \leq 1 - R_{class}(h), where Rclass(h)R_{class}(h) is the expected probability that h preserves its decision under small input perturbations. For non-localized attacks, we propose an empirical calibrated model. For LLM-as-a-Judge systems, we separate instructive and content attacks and develop ASA, an adaptive evolutionary attack that combines token-level mutations with semantic paraphrasing. Under black-box access, ASA reaches an attack success rate (ASR) of up to 73.8%, and the transfer success rate between open models reaches 62.6%. On Trojan Detection Challenge 2023 data for Pythia-1.4B, we quantify an asymmetry of trojan detection: surrogate triggers reach a reverse-engineered attack success rate (REASR) of ≈0.99\approx 0.99, while the recall of the true triggers is ≈0.17\approx 0.17 against a baseline of ≈0.14\approx 0.14. On SaTML CTF 2024, we systematize four classes of bypasses of multi-layer defenses. Committees of 5–7 heterogeneous models reduce the ASR for Gemma-3-4B by 47–55 percentage points, from 73.8% to 19.3% with 7 models. The Condorcet jury theorem justifies the growth of committee accuracy when the members err independently and each has an accuracy above 0.5. For Gemma-3-4B, which does not meet this condition, the gain comes from the heterogeneity of the committee. Multi-layer defense reduces the ASR from 90% to 15–25%. For agentic systems based on the Model Context Protocol (MCP), we propose AttestMCP, which attests tool calls with HMAC-protected packets at an overhead below 0.1 ms per call, and the Commit Boundary isolation pattern. On the MCPBench benchmark of 847 scenarios, our defenses reduce the average ASR from 53.7% to 12.4%. The methods are implemented in the registered software suites JudgeGuard and TrojanArmor and in the MCPSec module. JudgeGuard is deployed in production at Viasat.

Contents

Introduction 4

1 Analysis of Threats and Vulnerabilities of Large Language Models 11
1.1 Theoretical Foundations of Large Language Model Robustness 11
1.1.1 Large Language Models: A Formal Representation 11
1.1.2 LLM Robustness: Definition and Significance 12
1.1.3 LLM Vulnerabilities and Attack Types 14
1.1.4 Categorization and Formalization of Specific Aspects of Vulnerabilities 15
1.2 Classification and Analysis of Security Threats to Large Language Models 16
1.2.1 Basic Definitions and Formal Metrics 17
1.2.2 Description of the Main Threat Types 17
1.2.3 Threat Categorization 20
1.2.4 Mapping to Security Frameworks 20
1.2.5 Illustrative Threat Examples 22
1.2.6 Analysis of Threat Interrelations 23
1.2.7 Conclusions and Risk Mitigation Recommendations 24
1.2.8 Formalization of the Threat Space for Large Language Models 25
1.3 Risks, Limitations, and Ethical Aspects 28

2 Theoretical Foundations for Evaluating the Robustness of Large Language Models 29
2.1 Problem Statement and Threat Model 29
2.1.1 Formalization of the Robustness Evaluation Problem 29
2.1.2 Assumptions About the Adversary 30
2.1.3 Classification of Adversarial Actions 31
2.1.4 Formalization of the Security of an LLM as a Service 31
2.2 Formal Robustness Metrics 32
2.2.1 The Metric Rclass(h)R_{class}(h) for Discrete Outputs 32
2.2.2 The Metric Rstab(f)R_{stab}(f) for Generative Models 32
2.2.3 The Global Vulnerability Index V(f)V(f) 34
2.2.4 The Risk Function Risk( a,fa, f) 35
2.3 Properties of and Relations Between the Metrics 36
2.3.1 The Monotonicity Property of Rclass(h)R_{class}(h) and Rstab(f)R_{stab}(f) 36
2.3.2 An Upper Bound on Vulnerability Through Robustness: V≤1−RclassV \leq 1 - R_{class} 37
2.3.3 Lemma on Model Composition 39
2.4 Analytical Estimates and Upper Bounds 40
2.4.1 Upper Bounds on Rclass(h)R_{class}(h) for Bounded ε\varepsilon 40
2.4.2 Estimating Vulnerability to Adaptive Attacks 41
2.4.3 Asymptotic Properties as the Dataset Size →∞\rightarrow \infty 41
2.5 Robustness of Compositional Systems 42
2.5.1 LLM + Retriever Pipelines 42

2.5.2 Recursive Chains of LLM Agents ..... 43
2.5.3 Majority-Vote Ensembles ..... 45
2.6 Comparison with Existing Metrics ..... 46
2.6.1 Completeness Criteria ..... 46
2.6.2 Application of the Metrics: Model Comparison ..... 47
2.6.3 Relation Between the Theoretical Metric Rstab(f)R_{stab}(f) and Empirical Indicators ..... 47
2.7 Chapter Conclusions ..... 47

3 Methods for Improving the Robustness of Large Language Models ..... 49
3.1 Theoretical Foundations of Robustness Improvement ..... 49
3.1.1 Formalization of Robustness and Local Sensitivity ..... 49
3.1.2 Robustness Metrics for LLMs ..... 51
3.2 Architecture-Level Methods for Improving Robustness ..... 51
3.2.1 Modification of the Transformer Architecture ..... 51
3.2.2 Multi-Layer Defense with a Focus on Robustness ..... 54
3.3 Training-Level Methods for Improving Robustness ..... 56
3.3.1 Robust Training ..... 56
3.3.2 Knowledge Distillation for Improving Robustness ..... 57
3.3.3 Theoretical Limitations and Trade-offs ..... 58
3.4 Algorithmic Implementation and Complexity Analysis ..... 58
3.4.1 Pseudocode of the Model Committee Pipeline ..... 58
3.4.2 Conceptual Algorithm of the ASA Attack ..... 59

4 Experimental Evaluation of Robustness Enhancement Methods ..... 61
4.1 Experimental Evaluation Methodology ..... 61
4.1.1 Robustness Evaluation Criteria ..... 61
4.1.2 Evaluation Datasets ..... 63
4.1.3 Experimental Procedure ..... 64
4.2 Experimental Evaluation Results ..... 65
4.2.1 Vulnerability of LLM-as-a-Judge to Prompt Injection Attacks ..... 65
4.2.2 Trojan Detection in LLMs ..... 67
4.2.3 Attacks on LLMs with a Multi-Layer Defense ..... 68
4.2.4 Analysis of Parameter Effects and Trade-offs ..... 69
4.2.5 Empirical Validation of the Relation between Rstab(f)R_{stab}(f) and Rclass(h)R_{class}(h) ..... 69

5 Software Implementation of the Suite for Evaluating and Improving LLM Robustness ..... 72
5.1 Architectural Model of the JudgeGuard and TrojanArmor Software Suites ..... 72
5.1.1 Modular Structure of the System ..... 72
5.1.2 Component and Data Flow Diagram ..... 73
5.1.3 Data Processing Pipeline ..... 73
5.2 Choice of the Technology Stack and Tools ..... 74
5.2.1 Core Technologies ..... 74
5.2.2 Performance Comparison of vLLM and the Standard HuggingFace Pipeline ..... 74
5.3 Module for Evaluating the Robustness of Agentic LLM Systems (MCPSec) ..... 75
5.3.1 Architecture of the Model Context Protocol ..... 75
5.3.2 Interaction Sequence Diagram ..... 76
5.3.3 Protocol Vulnerabilities: From Prompt Injection to Tool Hijacking ..... 76
5.3.4 Experimental Evaluation of Protocol Vulnerabilities: MCPBench ..... 77
5.3.5 Algorithmic Support for the Security of Agentic Interaction ..... 77
5.4 Evaluation of the Computational Complexity and Performance of the Software Suite ..... 81
5.4.1 Latency Analysis as a Function of Context Length ..... 81

5.4.2 Throughput Comparison Across Configurations ..... 81
5.4.3 Scalability in Multi-Model Evaluation ..... 82
5.4.4 Computational Overhead of the Security Algorithms ..... 83
6 Practical Application of Robustness Enhancement Methods ..... 85
6.1 Methodology for Deploying Robustness Enhancement Methods ..... 85
6.1.1 Stages of Deploying Robustness Enhancement Methods ..... 85
6.1.2 Evaluation of Deployment Effectiveness ..... 87
6.2 Examples of Practical Application ..... 88
6.2.1 Application in Natural Language Processing Systems ..... 88
6.2.2 Application in Critical Systems ..... 89
6.3 Prospects for the Development of Robustness Enhancement Methods ..... 90
6.3.1 Research Trends and Directions ..... 90
6.3.2 Technology Development Forecasts ..... 91
Conclusion ..... 93
Acknowledgements ..... 95
List of Abbreviations and Notation ..... 96
Glossary ..... 100

References (100)

Couldn't load all references. Reload the page to try again.