TRACER: Trace-Regularized Training Against Indirect Prompt Injection
Organizations: Mohamed bin Zayed University of Artificial Intelligence Abu Dhabi, United Arab Emirates
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.
Figures & tables
| (a) Attack generalization | (b) Objective ablation | (c) Valid evidence + injection | |||||||
| Setting | Base | TRACER | Variant | ATRC | ASR | Channel | Ev. acc. | Base flip | TRACER flip |
| Original | 65.5 | 6.1 | Base | no | 65.5 | RAG | 83.0 | 58.1 | 13.8 |
| Held-out paraphrase | 62.7 | 10.0 | Answer-only | no | 21.3 | Tool | 82.5 | 52.5 | 17.5 |
| Channel-aware | 68.8 | 18.1 | Composite reward | no | 13.8 | Agent | 81.0 | 46.3 | 16.3 |
| Defense-aware | 70.0 | 23.8 | Full TRACER | yes | 6.1 | ||||
Appendix figures & tables18 assets
Supplementary material from the paper’s appendix.
Appendix
| Attack family | Goal | Train/evaluation relation |
|---|---|---|
| Reasoning rewrite | Replace the solution path with an alternative chain | Disjoint tasks + held-out paraphrases |
| Preemptive answer | Inject a false “verified” final answer | Disjoint tasks + held-out paraphrases |
| Prompt injection | Issue an explicit instruction override | Disjoint tasks + held-out paraphrases |
| RAG evaluation | Base | TRACER |
|---|---|---|
| Original templates | 65.5% | 6.1% |
| Held-out paraphrases | 62.7% | 10.0% |
| Channel-aware escalation | 68.8% | 18.1% |
| Defense-aware suite | 70.0% | 23.8% |
| Signal | Used in | Implementation | Used by evaluation? | Audit |
|---|---|---|---|---|
| Evidence validity | Corrigibility, ATRC gate | Construction label | No | Exact |
| Step validity | Process reward | Verifier + rules | No | 90.0% agreement |
| Anchor support/contradiction | Anchor reward | Verifier | No | 91.0% agreement |
| Final-answer correctness | Accuracy, ASR | Answer extraction | Yes | 99.5% agreement |
| Result | ASR | Successes/denom. | Wilson 95% CI |
|---|---|---|---|
| Follow-up eval. average | 18.0% | 173/960 | [15.7, 20.6] |
| RAG eval. average | 53.0% | 509/960 | [49.9, 56.2] |
| Base RAG | 65.6% | 99/151 | [57.7, 72.7] |
| TRACER RAG | 6.1% | 10/164 | [3.3, 10.9] |
| Mixed-evidence channel | Evidence acc. | Base flip ASR | TRACER flip ASR |
|---|---|---|---|
| RAG document | 83.0% | 58.1% | 13.8% |
| Tool output | 82.5% | 52.5% | 17.5% |
| Agent message | 81.0% | 46.3% | 16.3% |
| Model | Follow-up | RAG | Tool | Agent | Spread |
|---|---|---|---|---|---|
| Qwen2.5-3B-Instruct | 41.4% | 65.5% | 59.4% | 46.5% | 24.1 |
| Qwen2.5-7B-Instruct | 9.5% | 34.3% | 36.6% | 16.8% | 27.1 |
| Llama-3.1-8B-Instruct | 17.8% | 42.5% | 39.0% | 24.0% | 24.7 |
| Gemma-2-9B-It | 12.0% | 31.5% | 34.0% | 19.0% | 22.0 |
| Mistral-7B-Instruct | 24.5% | 49.0% | 45.5% | 30.5% | 24.5 |
| Model | Followup | RAG | Tool-Output | Agent-Msg | Spread |
|---|---|---|---|---|---|
| 3B Base (no LoRA) | 41.4% | 65.5% | 59.4% | 46.5% | 24.1 |
| 3B RAG-trained | 14.5% | 6.1% | 25.7% | 26.5% | 20.4 |
| 3B Tool-trained (epoch 1) | 32.1% | 33.1% | 39.6% | 40.3% | 8.2 |
| 3B Tool-trained (final) | 20.0% | 20.2% | 15.0% | 15.8% | 5.2 |
| 3B Multi-framing (RAG+tool) | 11.3% | 5.2% | 21.7% | 17.5% | 16.5 |
| 3B Agent-trained | 19.6% | 15.7% | 26.3% | 18.4% | 10.6 |
| State | Epoch | Clean | Robust | ASR |
|---|---|---|---|---|
| Base | – | 64.0% | 24.5% | 59.4% |
| step-250 | 1 | 66.0% | 32.5% | 57.6% |
| step-1750 | 1 | 72.0% | 52.0% | 39.6% |
| step-2500 | 2 | 73.0% | 58.5% | 32.2% |
| step-2750 | 2 | 69.5% | 60.5% | 28.8% |
| final | 3 | 77.5% | 75.5% | 15.0% |
| State | Followup | RAG | Tool | Agent | Avg |
|---|---|---|---|---|---|
| Base | 41.4% | 65.5% | 59.4% | 46.5% | 53.2% |
| Epoch 1 | 21.0% | 30.3% | 43.3% | 31.9% | 31.6% |
| Epoch 2 | 12.4% | 21.8% | 20.1% | 23.4% | 19.4% |
| Final | 19.6% | 15.7% | 26.3% | 18.4% | 20.0% |
| Condition | Sys | Wrapper | ASR | |
|---|---|---|---|---|
| Full | RAG | RAG | 5.5% | — |
| Wrapper only | Default | RAG | 10.0% | +4.5 |
| Prompt only | RAG | None | 11.3% | +5.8 |
| Neither | Default | None | 60.5% | +55.0 |
| Model | Followup | RAG | Tool | Agent | Avg |
|---|---|---|---|---|---|
| 7B Base | 9.5% | 34.3% | 36.6% | 16.8% | 24.3% |
| 7B RAG ep1 | 5.2% | 10.4% | 13.5% | 8.5% | 9.4% |
| 7B RAG ep2 | 5.7% | 18.0% | 19.2% | 6.5% | 12.3% |
| 7B RAG final | 5.1% | 13.6% | 18.2% | 6.2% | 10.8% |