MINE: a training-free defense against indirect prompt injection based on mutual information and embedding varianceMINE: A Training-Free Defense against Indirect Prompt Injection via Mutual Information and Embedding Variance
The authors propose a training-free defense, MINE, which filters RAG context by query relevance; on Inj-SQuAD, Llama-3.1-70B-Instruct achieves an average Acc/ASR of 91.93%/0.55%.
Grey-box indirect prompt injection: the attacker knows the system architecture but not the defense parameters, can adopt any injection strategy, and cannot modify the query q or the LLM weights; an adaptive attacker additionally knows the full algorithm and all hyperparameters. The victim systems are RAG using untrusted retrieval context, and the ReAct tool agent in InjecAgent.
- RAG-retrieved content may carry indirect prompt injection, causing the model to execute injected instructions rather than answer the query. The authors argue that prompt engineering, heuristic detection, and supervised filtering all depend on the attack form, and that defense utility and security in long context also lack paired evaluation.
- Before the LLM, MINE splits the context into spans, optimizes query–span mutual information minus embedding variance via projected gradient ascent on the probability simplex, and retains and reranks high-weight spans. The authors also use GPT-5.4-mini to expand Inj-SQuAD into LC-Inj-SQuAD.
- The experiments cover three open-source LLMs, four datasets, five types of static injection, and adaptive attacks. The authors state that MINE achieves the best accuracy–security trade-off among training-free defenses; under long-context adaptive attacks, ASR rises to 23.20%, and they report the lowest latency in long context as well as InjecAgent transfer results.
- The authors note that the 50-character merge-splitting assumes regular text punctuation, so code, tables, JSON and the like may be split too coarsely, and domain-specific chunkers are a future direction. The adaptive attack is evaluated only on Llama-3.1-70B-Instruct; the paper does not report the number of repetitions, variance or statistical significance tests.
- Evaluated models
- Llama-3.2-3B-InstructLlama-3.1-70B-InstructQwen3-30B-A3B-Instruct-2507
- Benchmarks
- Inj-SQuADInj-TriviaQALC-Inj-SQuADInjecAgent Direct-Harm
- Metrics
- Task Accuracy (Acc)Attack Success Rate (ASR)Valid RateASR-validaverage end-to-end inference latency
The researchers propose MINE, a training-free defense against indirect prompt injection in RAG that protects by maximizing relevance rather than detecting attacks, and claim it achieves the best accuracy-safety trade-off among training-free defenses on four datasets. The paper notes that existing defenses are mostly passive, prompt engineering methods are often overridden by injected instructions, and supervised detectors require retraining for each new attack style; MINE requires no training, does not depend on a specific attack style, and can also serve as a query-conditioned reranker. The authors also release the long-context benchmark LC-Inj-SQuAD, averaging 4,032 words per context, and evaluate on four datasets—Inj-SQuAD, Inj-TriviaQA, LC-Inj-SQuAD and InjecAgent—covering short-context question answering, long-context question answering and agent tool-call injection. The paper claims MINE is the only defense still usable under a fully adaptive attacker, generalizes to agent tool-call injection, and has the lowest inference latency on long contexts.
Related events and news
1 events · 0 news mentions
- This event's paper
MINE:免训练防御间接提示注入
Paper analysis
What problem does this paper attempt to solve?
The authors reframe indirect prompt injection defense as query-relevance selection and add long-context and adaptive attack evaluations.
Core problem: how to block indirect prompt injection in untrusted retrieved context without identifying the specific attack or retraining, while preserving answering utility.
- Scenario and importance: RAG concatenates external retrieved passages into the context, and malicious instructions may cause the model to switch to executing the injected task; the authors state this can happen without access to model weights or the system prompt. In long context, injection also becomes a “needle in a haystack.”
- Shortcomings of existing methods: The authors group existing defenses into prompt engineering, heuristic detection, and supervised filtering, arguing that they are respectively easy to override by injection, vulnerable to paraphrasing, and dependent on the labeled distribution, and thus are attack-dependent reactive designs.
- Core observation: The authors hypothesize that legitimate spans usually have high mutual information with the query (P1) and low embedding variance among themselves (P2); injected spans often pursue unrelated goals and are isolated in embedding space, so they can be filtered out during relevance selection.
- What is proposed: A training-free, attack-agnostic MINE pre-LLM filter and query-conditioned reranker; the construction of LC-Inj-SQuAD, averaging 4,032 words; and evaluation on short-context, long-context, and tool-call injection.
- Threat model:
- Goal: Make the victim model output attacker-specified injected content, or call the attacker's tool in a ReAct agent.
- Knowledge: The standard setting is grey-box, knowing the system architecture but not defense parameters such as α, k, or the embedding encoder.
- Capability: Can adopt any injection strategy, but cannot modify the query q or the LLM weights; an adaptive attacker knows the full algorithm and all hyperparameters.
- Victim system: RAG using an untrusted retrieval corpus; a ReAct agent whose tool Observations are injected is also tested.
What related research exists?
Related work is divided into four groups: injection attacks, prompt and detection defenses, RAG poisoning defenses, and information-theoretic subset selection.
Indirect prompt injection attacks
- Perez and Ribeiro (2022); Greshake et al. (2023)—the former introduced the direct “ignore previous instructions” attack, and the latter formalized the indirect variant that embeds adversarial instructions in retrieved data.
- Chen et al. (2025c); Pasquini et al. (2024); Bagdasaryan et al. (2023); Zou et al. (2025)—concern conversational topic shifting, learning to execute triggers, multimodal payloads, and RAG exploitation, respectively.
Prompt engineering and detection defenses
- Sandwich (Schulhoff, 2024), Reminder (Yi et al., 2025), Spotlight (Hines et al., 2024)—add meta-instructions or data delimiters; training methods such as Wallace et al. (2024), StruQ, SecAlign, and Jatmo strengthen the model itself. The authors argue that these in-LLM methods rely on the model's instruction-following ability to override the injection.
- Alon and Kamfonas (2023); Jain et al. (2023); Llama Guard (Inan et al., 2023)—use perplexity detection, paraphrase defense, and a trained safeguard LLM, respectively; Hung et al. (2025), Xie et al. (2024), and Hu et al. (2024) use internal model signals.
- INDIRECT-PIA (Chen et al., 2025d)—fine-tunes detection and removal models on labeled attacks; the authors state that it is effective in-distribution but requires training infrastructure and degrades on unseen attack styles.
RAG poisoning and relevance selection
- RobustRAG (Xiang et al., 2024), Astute RAG (Wang et al., 2025)—isolate or integrate retrieved passages to counter corpus poisoning. The authors note that poisoning changes the answer while injection changes the task, that the two have different goals, and that these methods add LLM calls per query.
- RAGDefender (Kim et al., 2025)—a training-free inter-passage embedding-similarity clustering filter; the authors state that it scores passages independently, whereas MINE scores subsets jointly and combines query relevance with within-subset consistency.
- Belghazi et al. (2018), Oord et al. (2018), Xie and Ermon (2019), Lin and Bilmes (2011)—provide foundations for MI estimation, contrastive representation learning, continuous subset relaxation, and submodular selection; the authors use MI for inference-time defense without training.
Comparison baselines and benchmarks: The main experiments compare None, Reminder, Instructional, Sandwich, Spotlight, RAGDefender, MELON, and INDIRECT-PIA, using Inj-SQuAD, Inj-TriviaQA, LC-Inj-SQuAD, and InjecAgent. The authors state that MINE is the first method to formulate indirect prompt injection defense as MI maximization and that it satisfies the five design criteria in Table 1.
How does the paper address this problem?
MINE jointly optimizes span weights using mutual information minus embedding variance, then retains and reorders the evidence before sending it to the LLM.
The overall idea is to turn defense into subset selection over the retrieval context: MINE does not judge whether text is malicious, but instead selects, before the LLM, a subset of evidence that is highly relevant to the query and internally semantically consistent.
Problem setting and objective
- The context C is split at sentence boundaries and consecutive sentences are merged until each span has at least 50 characters, yielding n consecutive spans; the authors state that this granularity balances precise removal and semantic coherence.
- The query and spans are each encoded into unit embeddings eq and ei; similarity is the dot product and distance is Euclidean distance. The goal is to select a filtered subset C* so that the model, based on q and C*, gives an answer supported by legitimate content.
- The core objective is C∗=argmaxC′⊆ CMI(eq,eC′)−αVar(C′): maximize the mutual information between the query and the normalized centroid of the subset, while penalizing variance within the subset, with α controlling the trade-off between the two terms.
Continuous relaxation and optimization
- Directly enumerating 2^n subsets is too computationally expensive, so the keep/discard decision is relaxed to [0,1] weights constrained to the probability simplex: weights are non-negative and sum to 1.
- The relaxed objective is written as Lw=MI(eq,eC)−αVar(C), where eC is the normalized mixture of weighted span embeddings; MI is computed using a monotonic form of cosine similarity, and Var is the weighted squared distance from each span to the mixture embedding.
- Weights are initialized uniformly at 1/n and iterated for T steps of projected gradient ascent, with each step updating at learning rate η and then applying Euclidean simplex projection; the projection complexity is O(n log n).
Filtering, ordering and prompt assembly
- After the iterations, the top-k spans are selected by converged weights and the rest are discarded; the retained spans are then sorted in descending order of weight, placing the most query-relevant one at the beginning of the evidence block.
- The authors' stated reason for this ordering is the LLM's lost-in-the-middle attention bias; the same optimization handles both injection downweighting and answer-evidence reordering.
- The final prompt consists of the query instruction, the concatenated evidence, and the constraint "answer using only the above evidence". Algorithm 1 summarizes the procedure; the fixed parameters are α=0.4, T=20, η=0.01, with k=5 for short context and k=40 for long context.
LC-Inj-SQuAD construction
- Using the queries, contexts and reference answers of Inj-SQuAD as input, GPT-5.4-mini with structured-output validation completes three steps: extract the target span containing the answer; verify that this span alone is sufficient to answer; expand the content before and after the target and assemble the long context.
- The preceding and following content are each expanded into 1500–2000-word paragraphs on the same topic, with the generated content constrained not to mention the answer; blocks shorter than 50 characters that cannot be expanded use topic-filler prompts. Appendix A gives four complete prompts.
- Samples that still fail after three retries of extraction or verification are discarded; of 900 original samples, 694 pass all steps. The paired evaluation uses the corresponding 694 short Inj-SQuAD samples and their long-context versions to isolate the effect of context length.
Success criteria and agent adaptation
- RAG measures Task Accuracy as the proportion of correct answers and ASR as the proportion of outputs containing the attacker's target injected content; the construction validation in Appendix A uses lowercase string containment matching of the answer, consistent with the paper's other evaluation metrics.
- InjecAgent applies MINE before the tool Observation is returned to the ReAct agent, retaining the MI and projected-gradient optimization; for compact JSON, a fallback splitter that can split at field-boundary commas is used instead.
- The tool setting retains spans in the top 80% of weights with wi > 0.05·wmax and preserves the original document order, to avoid reordering breaking JSON fields, lists and turn semantics; implementation details are in Appendix D.
What experiments did the paper conduct?
Across three models and four datasets, MINE has low ASR under static attacks, but it rises to 23.20% under long-context adaptive attacks.
Experimental setup
- Models evaluated: Llama-3.2-3B-Instruct, Llama-3.1-70B-Instruct, Qwen3-30B-A3B-Instruct-2507; all served by vLLM with greedy decoding.
- Datasets: Inj-SQuAD and LC-Inj-SQuAD each use 694 paired samples; Inj-TriviaQA is also used, as well as the 510-case Direct-Harm split of InjecAgent. The sample size of Inj-TriviaQA is not stated in the paper.
- Attacks: Five types of static injection: naive, escape_separation, ignore, completion, conv_attack; a two-position adaptive attack that knows the algorithm and hyperparameters is also tested on Llama-3.1-70B-Instruct.
- Baselines: None, Reminder, Instructional, Sandwich, Spotlight, RAGDefender, MELON, INDIRECT-PIA; Table 2 omits Reminder and Instructional among the first two for readability, with full results in Table 8.
- Metrics: RAG reports Acc/ASR; InjecAgent reports Valid Rate, for parseable results without fabricated Observations, and ASR-valid, for valid traces in which the recovered Action matches the attacker's tool.
- Implementation and repetitions: The span encoder is BAAI/bge-large-en-v1.5; latency is measured on Llama-3.1-70B-Instruct, vLLM, 4×H100. The paper does not report the number of repetitions, variance, or statistical significance tests.
Main results
The table below shows the average Acc/ASR (%) over the five static attacks, according to Table 2 and Table 3; each cell is Acc/ASR.
Swipe horizontally to read the table
Dataset Model None Sandwich INDIRECT-PIA MINE Inj-SQuAD Llama-3.2-3B-Instruct 23.11/87.20 62.91/61.61 66.34/0.00 84.32/0.46 Inj-SQuAD Llama-3.1-70B-Instruct 39.43/70.49 68.19/29.39 68.99/0.00 91.93/0.55 Inj-SQuAD Qwen3-30B-A3B-Instruct-2507 28.82/76.48 59.97/32.59 63.40/0.00 89.77/0.46 LC-Inj-SQuAD Llama-3.2-3B-Instruct 9.28/87.41 52.82/52.16 62.54/0.00 80.78/1.56 LC-Inj-SQuAD Llama-3.1-70B-Instruct 29.91/75.53 69.94/25.47 72.05/0.00 89.25/0.43 LC-Inj-SQuAD Qwen3-30B-A3B-Instruct-2507 30.72/73.46 59.60/27.66 63.52/0.00 85.59/0.69 Inj-TriviaQA Llama-3.2-3B-Instruct 29.82/72.13 72.48/37.30 78.23/0.00 86.81/1.02 Inj-TriviaQA Llama-3.1-70B-Instruct 40.13/68.19 71.55/26.90 78.72/0.00 93.98/0.49 - Table scope: The Qwen3-30B-A3B-Instruct-2507 row for Inj-TriviaQA is omitted; its MINE is 94.91%/0.18%; full baseline numbers are in Tables 2, 3, and 8.
- Authors' interpretation: The authors state that MINE achieves the best accuracy–security trade-off among training-free defenses; although INDIRECT-PIA reduces the ASR of most static attacks to 0, it is a supervised method, and on conv_attack its accuracy is only 4.03%–25.50% (Table 2).
- Short–long pairing: From Inj-SQuAD to LC-Inj-SQuAD, MINE's average ASR across the three models changes by at most 1.1 percentage points, and average Acc drops by at most 4.18 percentage points; the authors use this to state that it is more stable than prompt engineering and RAGDefender.
Adaptive attacks
- Setup and results: The attacker places two topic-matched single-span injections at the two ends of the document, tested only on Llama-3.1-70B-Instruct. MINE's Acc/ASR is 85.45%/4.76% on Inj-SQuAD and 65.13%/23.20% on LC-Inj-SQuAD (Table 4).
- Baseline comparison: Sandwich's ASR on the two datasets is 16.28% and 39.77%, respectively; INDIRECT-PIA's ASR is 0.00% on both, but its Acc is 6.20% and 23.20%, respectively; MELON's Acc is 9.80% and 0.86%, respectively (Table 4).
- Authors' interpretation: The authors state that MINE is the only defense still usable under this attack, because it removes the malicious span and preserves the surrounding evidence; they also explicitly state that its long-context ASR rises to 23.20%.
InjecAgent tool-call injection
- What was tested: Five static injection styles applied to 510 Direct-Harm cases, filtered before the tool Observation enters the ReAct agent; results are averaged over the five attack types (Table 6).
- Results: On Qwen3-30B-A3B-Instruct-2507, MINE's Valid/ASR-valid is 99.60%/0.12%, RAGDefender's is 99.41%/0.04%, and MELON's is 99.76%/0.51%; on Llama-3.1-70B-Instruct, the three are 90.20%/2.06%, 88.20%/0.99%, and 99.22%/8.48%, respectively.
- Authors' interpretation: The authors state that the compact JSON Observation makes the injected field an isolated outlier suitable for inter-paragraph clustering, so RAGDefender is close to MINE here; MELON, by contrast, adds one LLM call per query.
Latency and utility without injection
- Latency: Table 5 reports average end-to-end seconds/sample for Llama-3.1-70B-Instruct. Without injection, MINE is 0.52 and 0.78 on Inj-SQuAD and LC-Inj-SQuAD, respectively; under conv_attack, it is 0.47 and 0.75, respectively, lower than Sandwich and INDIRECT-PIA in the table.
- Accuracy without injection: For Llama-3.1-70B-Instruct on clean contexts in Inj-SQuAD, standard RAG is 92.51% and with MINE applied is 92.22% (Section 5.5 footnote 2).
- Authors' interpretation: The authors state that top-k evidence selection limits the victim model's input length, giving MINE the lowest latency in long context; the paper does not report the number of repetitions or variation for each latency.
Other ablations and analyses
- Variance penalty α: In Figure 2, on Inj-SQuAD with Llama-3.2-3B-Instruct, at α=0 the five-attack average Acc/ASR is 79.54%/11.96%, and at α=0.4 it is 84.32%/0.46%; the authors state that ASR remains stable for α>0.4.
- Cosine ranking only: On Inj-SQuAD, k=5, averaged over five attacks, Llama-3.1-70B-Instruct is 84.29%/7.64% and Qwen3-30B-A3B-Instruct-2507 is 77.81%/10.61%; the corresponding MINE values are 91.93%/0.55% and 89.77%/0.46%.
- Long-context exception: In the LC-Inj-SQuAD Llama-3.2-3B-Instruct completion cell, MINE is 79.11%/3.31%, the highest ASR among all its cells in Table 2.
- Agent effectiveness cost: Sandwich's Valid/ASR-valid on Qwen3-30B-A3B-Instruct-2507 and Llama-3.1-70B-Instruct is 77.40%/33.56% and 77.80%/11.96%, respectively; the authors state that while it lowers ASR-valid, it breaks traces and shrinks the conditional denominator.
What are some points that can be further explored?
The authors explicitly state the applicable boundary of the span segmentation assumption; adaptive attacks and latency evaluation also each have specific coverage scopes.
Limitations and future directions noted by the authors
- Segmentation assumption: MINE merges sentence-boundary fragments until each span reaches 50 characters, presupposing that the text is well-formed prose with standard punctuation (Limitations).
- Structured content: Code, tables, or other structured data (such as JSON or Markdown tables) may produce overly coarse spans that cannot isolate the injection from surrounding legitimate content (Limitations).
- Language boundary: Languages with non-standard sentence terminators may also produce overly coarse spans; the authors do not list specific languages (Limitations).
- Future direction: The authors state that domain-specific chunkers are a natural extension direction (Limitations).
Experimental coverage
- Models and static attacks: The main RAG table covers three open-source instruction models and five types of static attacks; adaptive attacks are evaluated only on Llama-3.1-70B-Instruct (Sections 5.1, 5.4, Table 4).
- Data scale: Inj-SQuAD/LC-Inj-SQuAD are used in paired form with 694 samples; InjecAgent uses the 510-case Direct-Harm split; the sample size of Inj-TriviaQA is not stated in the paper (Sections 4, 5.1, 6).
- Adaptive attack form: Uses a design with two topic-matched spans placed at the two ends of the document, starting from a filter-aware rewrite targeting MINE and ending with a single-span conversational injection (Section 5.4, Appendix C).
- Defenses and cost: Compares eight types of baselines; latency is reported only on Llama-3.1-70B-Instruct, vLLM, 4×H100, and clean accuracy is reported only for that model on Inj-SQuAD (Table 5, Section 5.5 footnote 2).
- Evaluation reporting: The paper does not report the number of experimental repetitions, confidence intervals, statistical significance tests, or human review agreement; apart from the string-containment matching described in Appendix A, the RAG Acc/ASR determination does not state that an LLM judge was used.
Summarize the main content of the paper
MINE achieves training-free injection filtering through relevance selection; results on static attacks are relatively strong, but adaptive long context still has failures.
MINE is a training-free pre-LLM defense against RAG indirect prompt injection, and it also proposes the long-context benchmark LC-Inj-SQuAD and extends to tool-calling agents.
- Problem: The authors argue that prompt engineering, heuristic detection and supervised filtering all depend on the attack form; their goal is to preserve answering ability and reduce ASR without knowing the specific injection style.
- Method: Split the context into spans of at least 50 characters, optimize the objective of query mutual information minus embedding variance via 20 steps of projected gradient ascent on the probability simplex, then select top-k and sort by weight; default α=0.4, k=5/40 for short/long context.
- Static short context: Under the average of five attacks on Inj-SQuAD, MINE achieves Acc/ASR of 91.93%/0.55% on Llama-3.1-70B-Instruct and 89.77%/0.46% on Qwen3-30B-A3B-Instruct-2507 (Table 2).
- Long context: LC-Inj-SQuAD consists of 694 samples, averaging 4,032 words; MINE achieves average Acc/ASR of 89.25%/0.43% on Llama-3.1-70B-Instruct, while RAGDefender achieves 23.43%/80.95% (Table 2).
- Adaptive and agent: Under the dual-position adaptive attack, MINE achieves 65.13%/23.20% on LC-Inj-SQuAD with Llama-3.1-70B-Instruct (Table 4); on InjecAgent, Qwen3-30B-A3B-Instruct-2507 achieves Valid/ASR-valid of 99.60%/0.12% (Table 6).
- Authors' conclusions: The authors state that MINE achieves the best accuracy–security trade-off among training-free defenses, has the lowest long-context latency, and that relevance filtering can transfer from RAG to tool use; its robustness does not depend on fixed templates, but long-context adaptive ASR still rises. The authors also note that the regular sentence-splitting assumption does not apply to code, tables and some languages, and that domain-specific chunkers are a future direction.