arXiv(opens in a new tab)cs.LGOct 2026Cited by 1 paper on PaperVantage

Manuscript Offprint

arXiv:2610.19133

TRACER: Trace-Regularized Training Against Indirect Prompt Injection

Kshitij Mishra, Salem Lahlou, Nils Lukas

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

Abstract

Indirect prompt injection uses untrusted retrieved content, tool outputs, or agent messages to override an LLM's intended behavior. We show that defense robustness is channel-conditioned: the same attack succeeds 18% of the time as a follow-up message but 53% when placed in retrieved context. We propose TRACER (Trace-Regularized Adversarial Channel Exposure with Reward-shaping), a channel-aware adversarial training method that samples presentation wrappers and combines an answer-anchored, evidence-gated reward with ATRC, which aligns attacked reasoning with clean evidence when an injection is invalid. On GSM8K with Qwen2.5-3B-Instruct, TRACER reduces RAG-framed ASR from 65.5% to 6.1% while preserving 78–82% clean accuracy. Joint RAG+tool training achieves 13.9% average ASR across framings at 3B scale, while a single epoch at 7B reaches 9.4%. These results demonstrate that robust defenses must explicitly train and evaluate across deployment channels. Research work's codebase can be accessed at https://github.com/Mishrakshitij/TRACER.git.

1 Introduction

Modern LLM systems rarely operate on trusted prompts alone. Retrieval-augmented generation (RAG) pipelines ingest documents from search or knowledge bases (Lewis et al., 2020; Gao et al., 2023); tool-using assistants consume API outputs (Qin et al., 2024; Patil et al., 2024); and LLM agents act on observations from interactive environments (Liu et al., 2024) and on messages from other agents (Li et al., 2023). In each case, the model must act on text that it did not author and cannot fully trust. This creates the setting for indirect prompt injection: malicious instructions hidden inside external content rather than entered as direct user prompts (Greshake et al., 2023).

A central but under-tested assumption in this literature is that robustness transfers across presentation channels. If the same malicious payload is tolerated as a conversational follow-up, will it also be tolerated when wrapped as a retrieved document, a tool response with provenance metadata, or a message from another agent? Existing defenses are usually trained and evaluated within a single wrapper, so this question is rarely isolated directly.

We begin by empirically testing this transfer assumption. Specifically, we ask whether a model trained to resist malicious instructions in one presentation channel remains robust when the same attack content is re-wrapped in another. The answer is no: across six intermediate model snapshots trained against follow-up-style attacks, simply rewrapping the same attack strings as retrieved documents increases average ASR from 18% to 53%. The base model also exhibits a strong authority gradient, where the same payload is less effective as a casual follow-up than as a document, tool output, or agent message. We call this phenomenon the framing gap.

To address this gap, we propose TRACER (Trace-Regularized Adversarial Channel Exposure with Reward-shaping), a deployment-matched adversarial training framework that treats the channel of untrusted context as part of the optimization problem. TRACER combines a three-turn robustness game with two training components designed for indirect injection: an answer-anchored, evidence-gated composite reward for the post-attack response, and ATRC, a committed-span Adversarial Trace Recovery and Consistency loss that aligns attacked reasoning to clean anchor spans when injected evidence is invalid. This lets us ask not only whether a defense works in one wrapper, but whether the learned robustness transfers across wrappers with different authority cues. Our key contributions are:

Indirect Prompt Injection, the Framing Gap, and TRACER

Figure

Framing gap: increased attack success from wrapper authority cues. TRACER: Trace-Regularized Adversarial Channel Exposure with Reward-shaping. ASR: attack success rate.

Figure 1: Left: the same malicious payload is injected through different untrusted-context channels. Middle: changing only the wrapper creates a framing gap; apparent authority/provenance cues are one possible explanation for the measured effect. Right: TRACER trains on channel-sampled three-turn games using an answer-anchored, evidence-gated reward and ATRC trace alignment, and evaluates both native robustness and cross-framing transfer.

• Framing gap. We identify and quantify a channel-conditioning effect in indirect prompt injection: identical adversarial content becomes substantially more successful when presented through a different untrusted-context channel.

• Channel-aware training. We introduce TRACER, an adversarial training framework that combines wrapper-sampled channel exposure, an answer-anchored evidence-gated reward, and a committed-span ATRC trace-alignment loss to preserve clean reasoning under invalid injected evidence.

• Cross-framing evaluation. We show that transfer across wrappers is asymmetric, revealing a depth–breadth trade-off between native robustness and generalization. Multi-framing training gives the best 3B average performance, while 7B models substantially reduce the trade-off.

References (28)