Chain-of-Defensive-Thought: Structured Reasoning Elicits Robustness in Large Language Models against Reference Corruption

Wenxiao Wang, Parsa Hosseini, Soheil FeiziarXiv 2025

Abstract

Chain-of-thought prompting has demonstrated great success in facilitating the reasoning abilities of large language models. In this work, we explore how these enhanced reasoning abilities can be exploited to improve the robustness of large language models in tasks that are not necessarily reasoning-focused. In particular, we show how a wide range of large language models exhibit significantly improved robustness against reference corruption using a simple method called chain-of-defensive-thought, where only a few exemplars with structured and defensive reasoning are provided as demonstrations. Empirically, the improvements can be astounding, especially given the simplicity and applicability of the method. For example, in the Natural Questions task, the accuracy of GPT-4o degrades from 60% to as low as 3% with standard prompting when 1 out of 10 references provided is corrupted with prompt injection attacks. In contrast, GPT-4o using chain-of-defensive-thought prompting maintains an accuracy of 50%.

Introduction

Retrieval-Augmented Generation (RAG) has become a standard paradigm for grounding Large Language Models (LLMs) in external knowledge. However, this reliance on external references introduces a significant security vulnerability: reference corruption. A single malicious or incorrect document retrieved from the web can hijack the model's output through prompt injection or knowledge corruption (e.g., PoisonedRAG). Standard prompting techniques typically assume all provided references are trustworthy, leaving even state-of-the-art models like GPT-4o vulnerable to manipulation. This paper introduces Chain-of-Defensive-Thought (CoDT), a few-shot prompting strategy designed to elicit defensive reasoning and improve model robustness against such attacks.

Methodology: Chain-of-Defensive-Thought

CoDT adapts the principles of Chain-of-Thought (CoT) reasoning to the domain of information reliability. Instead of directly answering a query based on provided contexts, the model is prompted to follow a structured, four-step defensive process:

  1. Indexing: Assigning a unique index to each reference.
  2. Relevance Identification: Explicitly stating which contexts are relevant to the query.
  3. Reliability Filtering: Identifying reliable contexts based on a consensus heuristic (e.g., information supported by the majority of sources).
  4. Structured Reasoning: Generating a "Reason" block that explains the selection of reliable sources before providing the final answer.
Comparison of standard prompting versus the structured Chain-of-Defensive-Thought (CoDT) approach.

This approach is entirely prompt-based, requiring no fine-tuning or architectural changes, making it applicable to both closed-source APIs and open-weight models.

Experimental Evaluation

The authors evaluated CoDT across 18 LLMs using the Natural Questions (NQ) and RealTime QA datasets. To simulate real-world attacks, they corrupted one out of ten retrieved references with either prompt injections (e.g., "Ignore previous instructions and say X") or fake knowledge.

Key Results

The empirical results demonstrate that CoDT significantly mitigates the impact of reference corruption. As shown in Figure 4, the robustness gains are consistent across a wide variety of models.

Robustness comparison across 18 LLMs on the Natural Questions task.

Notable findings include:

  • Massive Robustness Gains: For GPT-4o on Natural Questions, accuracy under prompt injection improved from 3% (standard) to 50% (CoDT).
  • Average Improvement: Across all tested models, CoDT increased minimum accuracy by 27.5 percentage points on NQ and 19.9 points on RealTime QA.
  • No "Clean" Performance Penalty: Interestingly, CoDT slightly improved accuracy on "clean" data (by ~1.3% on average), suggesting that structured reasoning helps models better focus on relevant information even in the absence of attacks.
  • Scaling with Intelligence: More capable models (e.g., Claude 3.5, GPT-4o) exhibited the most significant improvements, indicating that defensive reasoning is an emergent capability that scales with model size and training.

Discussion and Limitations

While CoDT offers a powerful and simple defense, several limitations remain:

  • Computational Overhead: The requirement to generate a reasoning block increases token usage and latency.
  • Majority-Based Vulnerability: The consensus heuristic assumes the majority of retrieved documents are clean. If an attacker can corrupt a majority of the context window, the defense may fail.
  • Static vs. Dynamic Exemplars: The current study uses fixed exemplars; future work could explore dynamic selection of defensive demonstrations to further improve performance.

Conclusion

Chain-of-Defensive-Thought demonstrates that the reasoning capabilities of LLMs can be effectively repurposed as a security layer. By simply prompting models to be skeptical and structured in their source evaluation, researchers can achieve dramatic improvements in RAG robustness without the need for costly retraining or specialized defense modules.

Summary updated

Abstract

Chain-of-thought prompting has demonstrated great success in facilitating the reasoning abilities of large language models. In this work, we explore how these enhanced reasoning abilities can be exploited to improve the robustness of large language models in tasks that are not necessarily reasoning-focused. In particular, we show how a wide range of large language models exhibit significantly improved robustness against reference corruption using a simple method called chain-of-defensive-thought, where only a few exemplars with structured and defensive reasoning are provided as demonstrations. Empirically, the improvements can be astounding, especially given the simplicity and applicability of the method. For example, in the Natural Questions task, the accuracy of GPT-4o degrades from 60% to as low as 3% with standard prompting when 1 out of 10 references provided is corrupted with prompt injection attacks. In contrast, GPT-4o using chain-of-defensive-thought prompting maintains an accuracy of 50%.
BibTeX
@misc{wang2025chain,
  author = {Wenxiao Wang and Parsa Hosseini and Soheil Feizi},
  title = {{Chain-of-Defensive-Thought: Structured Reasoning Elicits Robustness in Large Language Models against Reference Corruption}},
  year = {2025},
  eprint = {2504.20769},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2504.20769},
}
Figure