[KongchangAI]
· 1 min read· 987 words

MINE: A New Training-Free Paradigm for Defending Against Indirect Prompt Injection

MINE: A New Training-Free Paradigm for Defending Against Indirect Prompt Injection

MINE defends against RAG indirect prompt injection without training by maximizing query relevance instead of detecting attacks.

The article introduces MINE, a defense against indirect prompt injection in RAG. Existing defenses are mostly reactive: prompt engineering is easily overridden, and supervised detectors require repeated retraining for new attacks. MINE instead draws on information theory, combining mutual information and embedding variance to perform query-conditioned reranking of retrieval results, pushing truly relevant passages to the front and diluting the influence of injected instructions. The method is training-free and attack-agnostic, and can be integrated directly into existing RAG pipelines. The paper also releases the long-context benchmark LC-Inj-SQuAD (averaging 4,032 words per context) and validates on four datasets: MINE achieves the best accuracy-security trade-off among training-free defenses, is the only method able to handle fully adaptive attackers, has the lowest inference latency in long contexts, and generalizes to agent tool-call injection scenarios.

Indirect Prompt Injection: A Core Threat to RAG Systems

Indirect prompt injection is one of the core security threats facing RAG (retrieval-augmented generation) systems. Attackers hide malicious instructions inside retrieved documents, tricking the model into performing unintended actions. Most existing defense strategies are "reactive": prompt-engineering approaches are easily overridden by injected instructions, while supervised detectors must be retrained for every new attack style. A recent paper proposes a fundamentally different approach—defending by maximizing relevance rather than detecting attacks. The method, called MINE, is training-free and attack-agnostic, and can also serve as a query-conditioned reranker.

MINE paper source screenshot

The Plight of Existing Defenses: The Limits of Reactive Thinking

The paper points out that current defenses against indirect prompt injection in RAG have structural flaws. Prompt-engineering methods try to constrain model behavior through system prompts, but injected instructions often override these constraints; supervised detectors require large amounts of labeled data and must be retrained whenever a new attack style appears, limiting their generalization.

This "detect-and-respond" paradigm is essentially a game of catching up with attackers. The authors of MINE argue that rather than trying to identify malicious content, we should fundamentally improve the model's ability to focus on legitimate queries—maximizing the relevance of retrieved content to the user query, thereby diluting the influence of injected instructions.

The threat model of indirect prompt injection deserves further elaboration. Unlike direct prompt injection (where users write malicious instructions directly into the input), indirect injection is carried by external content that the model "automatically trusts" while processing a task—retrieved web pages, PDFs, emails, database records, or even JSON returned by tools. Attackers don't need to touch the user; they only need to get malicious text into the retrieval corpus. The danger of such attacks lies in the fact that it's hard for the model to distinguish between "data to be read" and "instructions to be executed," since both share the same text channel. Common attack goals include inducing the model to leak system prompts, change its stance, call unauthorized tools, or perform privilege-escalation actions in agent scenarios. Understanding this is key to seeing why prompt hardening alone is insufficient—defenders must address the fundamental boundary-blurring problem of "data being mistaken for instructions."

MINE's Core Mechanism: Mutual Information and Embedding Variance

MINE's core idea is grounded in information theory. It uses mutual information to measure the relevance between retrieved passages and the user query, while combining embedding variance to assess content uncertainty. Through these two metrics, MINE can perform query-conditioned reranking of retrieval results, pushing truly relevant passages to the front and reducing the risk of interference from injected content.

The key advantage of this approach is that it is attack-agnostic: it does not rely on recognizing specific attack patterns, so it does not require retraining for new attacks. The paper emphasizes that MINE is "training-free," meaning it can be deployed directly into existing RAG pipelines without additional labeled data or model fine-tuning.

Mutual information comes from information theory and measures the degree of statistical dependence between two random variables: how much knowing one variable reduces uncertainty about the other. In retrieval scenarios, it can capture "how much the semantic uncertainty of a passage decreases given the query." Compared with metrics such as cosine similarity, mutual information has the advantage of not being limited to geometric distance in vector space, but focusing more on information-level relevance. Embedding variance reflects the degree of fluctuation of the same text across different representations or samples: semantically stable, clearly directed passages have lower variance, while ambiguous content open to multiple interpretations has higher variance. Instructions injected by attackers often exhibit semantic drift relative to the query topic and tend to show higher embedding variance. By combining the two, MINE simultaneously examines "whether it is relevant" and "whether it is stable," thereby prioritizing passages that are both aligned with the query and semantically determinate during reranking.

A New Benchmark, LC-Inj-SQuAD: Defense Evaluation in Long Contexts

To evaluate defense effectiveness under more realistic conditions, the paper proposes LC-Inj-SQuAD, a long-context benchmark in which each context averages 4,032 words. This benchmark fills a gap in existing evaluation—previous tests mostly focused on short-context scenarios, whereas real RAG systems often need to process long documents.

The experiments cover four datasets: short-context QA (Inj-SQuAD, Inj-TriviaQA), long-context QA (LC-Inj-SQuAD), and agent tool-call injection (InjecAgent). Across these diverse scenarios, MINE consistently demonstrates advantages.

SQuAD (Stanford Question Answering Dataset) is a classic benchmark in the QA and reading-comprehension field, containing question-answer pairs based on Wikipedia passages, and is often used as the underlying corpus for RAG evaluation. Inj-SQuAD is an attack evaluation set constructed by injecting malicious instructions into SQuAD, and Inj-TriviaQA is similarly based on the TriviaQA QA dataset. The key change brought by long contexts is this: the longer the context, the higher the probability that injected content gets "drowned out," but at the same time attackers gain more embedding positions and more covert construction space; the model's attention allocation in long documents is itself more diffuse, significantly increasing defense difficulty. In addition, long contexts amplify inference latency, which makes MINE's result of maintaining the lowest latency in long contexts more engineering-relevant.

Experimental Results: The Best Accuracy-Security Balance

On all four datasets, MINE achieves the best accuracy-security trade-off among training-free defense methods. More specifically, it is the only defense method that remains usable against a fully adaptive attacker, and it generalizes to agent tool-call injection scenarios.

In terms of inference latency, MINE achieves the lowest latency in long-context scenarios. This is crucial for real-world deployment—security defenses cannot come at the cost of response speed.

The paper's conclusion points in one direction: defending against indirect prompt injection does not have to be a perpetual cat-and-mouse game. By rethinking the defense objective—shifting from detecting attacks to maximizing relevance—MINE offers a more sustainable and easier-to-deploy path. For developers building RAG applications, this training-free, attack-agnostic defense approach is worth attention.

MINE paper source screenshot

#indirect prompt injection#RAG security#MINE#training-free defense#mutual information#embedding variance#LC-Inj-SQuAD#prompt injection defense
Share:

Related articles