UnsafeChain: Enhancing Reasoning Model Safety via Hard Cases

Raj Vardhan Tomar, Preslav Nakov, Yuxia WangarXiv 2025 · DOI

TL;DR

UnsafeChain introduces a novel safety alignment paradigm for Large Reasoning Models (LRMs) by focusing on "hard prompts"—adversarial or complex queries that typically trick models into generating harmful content. Instead of discarding these unsafe outputs, the authors use a powerful LLM to explicitly rewrite them into safe, step-by-step reasoning paths. This correction-based approach significantly boosts model robustness against jailbreaks while preserving, and sometimes even enhancing, general reasoning capabilities.

What Problem Does This Paper Address?

Large Reasoning Models (LRMs) leverage extended Chain-of-Thought (CoT) processing to excel at complex tasks like mathematics and coding. However, this advanced reasoning capability is a double-edged sword: it can amplify the persuasiveness or harmfulness of unsafe outputs, and models can even conceal malicious intent within their internal reasoning steps.

Existing Supervised Fine-Tuning (SFT) safety methods typically filter out any training examples where the model generates an unsafe response, opting to train exclusively on "easy prompts" that already yield safe answers or outright refusals. The authors argue this leaves a critical gap: models never learn how to recover when a hard prompt or adversarial jailbreak triggers an unsafe state. Consequently, weaker or distilled reasoning models remain highly vulnerable to sophisticated attacks.

Methods

The authors propose a correction-based safety alignment pipeline called UnsafeChain. The process unfolds in three main stages:

  1. Failure Identification: They run a diverse set of prompts through an unaligned base model (e.g., DeepSeek-R1-Distill-Llama-8B). Responses are evaluated using a safety classifier (LlamaGuard-7B). Prompts that successfully trigger unsafe responses are flagged as "hard prompts."
  2. Supervised Correction: Instead of throwing away these failures, they use GPT-4.1 to rewrite the unsafe completions. The model is instructed to generate a safe, ethical, and factually aligned response using an R1-style <think> ... </think> CoT format.
  3. Safety Verification: The corrected outputs are passed through LlamaGuard a second time to ensure they are completely safe before being added to the final dataset.
Figure 1: Overview of the UnsafeChain dataset construction pipeline.

Models are then fine-tuned on this dataset using Parameter-Efficient Fine-Tuning (PEFT) via LoRA adapters.

Datasets

The resulting UnsafeChain dataset consists of 13,604 training examples and 2,069 test examples balanced across six distinct domains, mixing adversarial safety with general-use reasoning tasks:

Extracted table from page 4 of UnsafeChain: Enhancing Reasoning Model Safety via Hard Cases

To test the "less is more" hypothesis, the authors also created two smaller 1K subsets:

  • UnsafeChain-Random-1K: A random sample preserving the overall domain diversity.
  • UnsafeChain-Selected-1K: A hand-curated "stress test" subset focusing exclusively on the hardest cases featuring unsafe or hallucinated completions prior to correction.

Key Insights and Ideas

  • Learning from Failure is More Effective Than Avoidance: Training models strictly on safe data (like the baseline dataset SafeChain) teaches them what a safe answer looks like but fails to teach them how to navigate away from an adversarial trap. Explicitly correcting unsafe trajectories provides a much stronger gradient for robust alignment.
  • Safety Alignment Doesn't Have to Tax Reasoning: A common issue in safety fine-tuning is "domain forgetting" or a "safety tax," where a model becomes overly cautious and loses its edge in math or coding. By mixing hard safety corrections with standard reasoning tasks (GSM8K, MBPP), UnsafeChain avoids behavioral drift and preserves core capabilities.
  • Data Quality Trumps Quantity: The curated UnsafeChain-Selected-1K subset consistently outperformed larger, loosely filtered datasets, proving that targeted exposure to hard failure modes is highly sample-efficient.

Key Results

The authors evaluated their approach across three model sizes (1.5B, 7B, and 8B) against prominent baselines like SafeChain and STAR-1 across 11 benchmarks.

  • Out-of-Distribution Generalization: Models fine-tuned on UnsafeChain showed superior safety performance on unseen jailbreak benchmarks like WildChat and JailbreakBench (JBB).
  • Preserving Capabilities: On general reasoning benchmarks like Math 500 and HumanEval, UnsafeChain-aligned models consistently outperformed SafeChain, which suffered from severe performance degradation due to a lack of math/code supervision during safety tuning.
Extracted table from page 7 of UnsafeChain: Enhancing Reasoning Model Safety via Hard Cases

The UnsafeChain-Selected-1K subset achieved 21 wins out of 36 evaluation settings compared to STAR-1, demonstrating the immense value of targeted, correction-based supervision.

Limitations and Future Work

Despite its strong performance, the authors note several limitations:

  • No Human Verification: The dataset relies entirely on automated corrections generated by GPT-4.1 and evaluations from LlamaGuard. This risks missing subtle, surface-level alignments that lack deeper semantic or ethical compliance.
  • Scale Constraints: The study focused primarily on smaller models (<10B parameters). The dynamics of SFT safety alignment might differ when applied to larger, frontier-class LRMs.
  • Future Directions: The authors plan to scale UnsafeChain to specialized domains like medical and legal fields, incorporate human-in-the-loop verification, and explore combining this SFT approach with Reinforcement Learning (RL) to further cement safety behaviors.
BibTeX
@misc{tomar2025unsafechain,
  author = {Raj Vardhan Tomar and Preslav Nakov and Yuxia Wang},
  title = {{UnsafeChain: Enhancing Reasoning Model Safety via Hard Cases}},
  year = {2025},
  eprint = {2507.21652},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2507.21652},
}