ReasAlign: Reasoning Enhanced Safety Alignment against Prompt Injection Attack

Hao Li, Yankai Yang, G. Edward Suh, Ning Zhang, Chaowei Xiao
1/15/2026
cs.CRcs.AIcs.CL

Official code: leolee99/ReasAlign (5 stars, last commit 2026-02-03).

Abstract

Large Language Models (LLMs) have enabled the development of powerful agentic systems capable of automating complex workflows across various fields. However, these systems are highly vulnerable to indirect prompt injection attacks, where malicious instructions embedded in external data can hijack agent behavior. In this work, we present ReasAlign, a model-level solution to improve safety alignment against indirect prompt injection attacks. The core idea of ReasAlign is to incorporate structured reasoning steps to analyze user queries, detect conflicting instructions, and preserve the continuity of the user's intended tasks to defend against indirect injection attacks. To further ensure reasoning logic and accuracy, we introduce a test-time scaling mechanism with a preference-optimized judge model that scores reasoning steps and selects the best trajectory. Comprehensive evaluations across various benchmarks show that ReasAlign maintains utility comparable to an undefended model while consistently outperforming Meta SecAlign, the strongest prior guardrail. On the representative open-ended CyberSecEval2 benchmark, which includes multiple prompt-injected tasks, ReasAlign achieves 94.6% utility and only 3.6% ASR, far surpassing the state-of-the-art defensive model of Meta SecAlign (56.4% utility and 74.4% ASR). These results demonstrate that ReasAlign achieves the best trade-off between security and utility, establishing a robust and practical defense against prompt injection attacks in real-world agentic systems. Our code and experimental results could be found at https://github.com/leolee99/ReasAlign.

View on arXivView PDF

Code Implementations(1)

leolee99/ReasAlignOfficial100%

The official implementation of the paper "ReasAlign: Reasoning Enhanced Safety Alignment against Prompt Injection Attack".

50Jinja, ShellSep 24, 20258 months ago

Similar Papers

Cite this paper

@article{li2026reasalign,
  title  = {ReasAlign: Reasoning Enhanced Safety Alignment against Prompt Injection Attack},
  author = {Hao Li and Yankai Yang and G. Edward Suh and Ning Zhang and Chaowei Xiao},
  year   = {2026},
  eprint = {2601.10173},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2601.10173v1}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2601.10173.svg)](https://codeofpaper.com/paper/2601.10173)

Discussion