Large language models are increasingly embedded into systems that interact with user data, retrieved web content, and external tools, creating a new attack surface: prompt injection, where malicious commands embedded in untrusted data override the trusted command and induce unintended behavior. Existing defenses mainly rely on fine-tuning the model to preserve an explicit boundary between trusted commands and the untrusted data portion, so that the model learns to prioritize the trusted field and ignore malicious commands in data. However, we observe that while these defenses can block obviously malicious responses caused by injected commands, they generalize poorly to real-world scenarios where the model's response to the injected command is much nearer to the correct response. This is because existing methods typically train against only a fixed set of hand-crafted attack targets, which yields a loose boundary around the correct response and leaves it easier to bypass.
To address this challenge, we propose LocalAlign, a more generalizable prompt injection defense inspired by adversarial training. LocalAlign automatically and efficiently generates adversarial examples in which the command embedded in the data portion induces a response that stays near to the correct response while still being wrong. We generate such near-but-wrong adversarial examples using prompting and a single inference step. This design enforces a tighter robustness boundary around the correct response: even small response shifts induced by commands in untrusted data are explicitly penalized. Moreover, the resulting adversarial examples can vary substantially in quality across samples. To address this issue, we further introduce a margin-aware alignment algorithm that quantifies each sample's distance to the correct response and assigns larger training weight to nearer ones.
Diffusion-Guided Adversarial Perturbation Injection for Generalizable Defense Against Facial Manipulations
College of Computer Science and Technology, National Huaqiao University(华侨大学计算机科学与技术学院);Xiamen Key Laboratory of Data Security and Blockchain Technology(厦门市数据安全与区块链重点实验室);Shenzhen Key Laboratory of Media Security, Shenzhen University(深圳大学媒体安全深圳市重点实验室);School of Cyber Science and Engineering, Sichuan University(四川大学网络空间科学学院);Zhejiang Key Laboratory of Artificial Intelligence of Things (AIoT) Network and Data Security(浙江省物联网(AIoT)网络与数据安全重点实验室)
DoubtProbe: Black-Box Jailbreak Defense via Structural Verification and Semantic Auditing
East China Normal University(东华大学);The Hong Kong University of Science and Technology (Guangzhou)(香港科技大学(广州));Institute of Information Engineering, Chinese Academy of Sciences(中国科学院信息工程研究所)