Manuscript Offprint

arXiv:2610.06401

RAISED: Self-Distillation for Robustness to Prompt Injection in LLM Agents

Mohamed Dhouib, Clement Elliker, Alexi Canesse, Maël Jenny, Lucas-Andrei Thil, Mahammed El-Sharkawy, Sonia Vanier, Elie Bursztein

ABSTRACT

Tool-using language-model agents are vulnerable to indirect prompt injection because they must act on untrusted external content. Existing training-time defenses can reduce attack success rates, but often at the cost of general capabilities. We show that training-based defenses induce substantial drift in the model's output distribution, altering its behavior even in benign settings and providing a potential mechanism for utility degradation. We further identify a failure mode of these defenses: On benign tool-use tasks, the model refrains from a step needed to finish an authorized task, particularly when that step is indicated by a tool output. To address these limitations, we introduce RAISED (Robust Attack Invariance through Self-Distillation), a training framework that combines self-generation and self-distillation. The model first generates its own tool-use scenarios, with an emphasis on cases where task completion requires acting on legitimate guidance from tool outputs. Then, through self-distillation, the student is trained to match the teacher's clean-context behavior on both clean and injected variants of the same trajectory. RAISED substantially reduces the attack success rate of prompt injections in tool responses while, unlike prior training-based defenses, preserving utility on both agentic and general-purpose benchmarks.

1 INTRODUCTION

Tool-using LLM agents are deployed as browsing assistants, coding assistants, and enterprise copilots, connected to emails, documents, CRM systems, and other services through APIs or the Model Context Protocol (MCP) Yao et al. (2023); Schick et al. (2023); Qin et al. (2023); Zhou et al. (2024); Wang et al. (2024a); Jimenez et al. (2024). Through these tools, agents process untrusted content from webpages, emails, documents and tool outputs. This exposes them to indirect prompt injection, where instructions hidden in that content hijack the agent away from its assigned task Greshake et al. (2023). Real-world attacks have already demonstrated this risk, including attacks that secretly extracted data from productivity tools Reddy & Gujral (2025) and manipulated MCP-based agents Beurer-Kellner & Fischer (2025); Wang et al. (2025). This growing threat has motivated a range of defenses, including prompting, filtering, and training-time alignment methods, all of which face a trade-off between robustness and utility Liu et al. (2024a): the model must resist adversarial instructions in untrusted tool outputs while still acting on the task-relevant guidance they may contain.

Training-based defenses aim to improve robustness while preserving benign behavior Chen et al. (2024; 2025). However, supervised fine-tuning (SFT) on targets drawn from an external source rather than the base model's own output distribution can shift the model away from its original behavior Yang et al. (2024). Preference-based defenses instead use direct preference optimization (DPO) to favor legitimate-task responses over responses to injected instructions Rafailov et al. (2024). Even when the preferred responses come from the original model, as in SecAlign++ (Chen

∗^{*}Equal contribution.

et al., 2026), DPO optimizes them relative to rejected responses on contexts containing injections without directly matching the model's predictive distribution on clean contexts.

Beyond general output-distribution drift, we identify a failure mode in training-based defenses: models execute benign tool-use tasks up to a point, then refrain from an authorized step that depends on guidance from a tool output. This leaves the task unfinished, even when the model is explicitly instructed to complete it end to end without further user involvement. The training objective creates an asymmetry: it consistently pushes the model away from responses that follow injected directions in tool outputs, while providing much less signal to follow legitimate actionable information from the same channel. The observed failures match a natural shortcut under this asymmetry: the model uses tool outputs as information but avoids acting on their guidance, even when doing so is necessary to complete the authorized task.

To address these limitations, we introduce RAISED, a framework combining self-generation and self-distillation. A frozen copy of the model being defended serves as both the data generator and the teacher, while a trainable copy serves as the student.

In the self-generation stage, the frozen model creates tool-use scenarios emphasizing cases where task completion requires acting on legitimate guidance from tool outputs. The same model generates both the clean task-solving trajectories and the injections for their tool outputs.

In the self-distillation stage, the student is trained on clean and injected contexts to match the teacher's next-token distribution on the corresponding clean context via KL divergence. On clean contexts, this limits output-distribution drift; on injected contexts, it trains the student to be insensitive to the injection while preserving legitimate tool-output guidance. Together, these target a model-relative robustness ideal: preserving the base model's behavior on clean contexts while recovering that behavior on their injected counterparts.

We evaluate RAISED on general-knowledge, agentic-capability, and prompt-injection benchmarks across different models and compare against undefended agents, prompting, filtering, and alignment-based defenses, measuring benign utility, utility under attack, and attack success rate (ASR). On AgentDojo with Gemma, RAISED reduces ASR from 39.5% to 1.0% and increases utility under attack from 64.0% to 80.5%, while losing only 1 point of benign utility. This matches the robustness of SecAlign++ without its 7-point drop.

Our contributions are threefold:

• We show that existing training-based defenses can induce output-distribution drift on benign settings and identify a behavioral failure mode in which defended models leave authorized tasks unfinished.

• We introduce RAISED, a framework that combines self-generation and self-distillation to train models to resist prompt injections while preserving their behavior on benign tasks.

• We show across three open-weight models and multiple general-knowledge, agentic-capability, and prompt-injection benchmarks that RAISED reduces attack success rates and improves utility under attack while preserving benign utility.

References (97)