When large language model (LLM) agents are increasingly deployed to automate tasks and interact with untrusted external data, prompt injection emerges as a significant security threat. By injecting malicious instructions into the data that LLMs access, an attacker can arbitrarily override the original user task and redirect the agent toward unintended, potentially harmful actions. Existing defenses either require access to model weights (fine-tuning), incur substantial utility loss (detection-based), or demand non-trivial system redesign (system-level). Motivated by this, we propose DataFilter, a test-time model-agnostic defense that removes malicious instructions from the data before it reaches the backend LLM. DataFilter is trained with supervised fine-tuning on simulated injections and leverages both the user's instruction and the data to selectively strip adversarial content while preserving benign information. Across multiple benchmarks, DataFilter consistently reduces the prompt injection attack success rates to near zero while maintaining the LLMs' utility. DataFilter delivers strong security, high utility, and plug-and-play deployment, making it a strong practical defense to secure black-box commercial LLMs against prompt injection. Our DataFilter model is released at https://huggingface.co/JoyYizhu/DataFilter for immediate use, with the code to reproduce our results at https://github.com/yizhu-joy/DataFilter.
Beyond Over-Refusal: Defending Indirect Prompt Injection via Latent Instruction Manifolds
Zhejiang University(浙江大学);Hong Kong Polytechnic University(香港理工大学);University of Science and Technology of China(中国科学技术大学);OPPO Research Institute(OPPO研究院)
ARGUS: Defending Against Multimodal Indirect Prompt Injection via Steering Instruction-Following Behavior
South China University of Technology(华南理工大学);Hong Kong University of Science and Technology(香港科技大学);Zhejiang Normal University(浙江师范大学);Beihang University(北京航空航天大学)
TextCrafter: Optimization-Calibrated Noise for Defending Against Text Embedding Inversion
Shenzhen International Graduate School, Tsinghua University(清华大学深圳国际研究生院);School of Data Science, The Chinese University of Hong Kong, Shenzhen(香港中文大学(深圳)数据科学学院)
Design and Implementation of a Secure RAG-Enhanced AI Chatbot for Smart Tourism Customer Service: Defending Against Prompt Injection Attacks -- A Case Study of Hsinchu, Taiwan
Department of Information Management, National Dong Hwa University(信息管理系,国立东华大学);By The Student (BTS) Experimental Education Program (Non-School Type)(学生(BTS)实验教育计划(非学校类型))
Defending against Indirect Prompt Injection by Instruction Detection
Renmin University of China(中国人民大学);Peking University Shenzhen Graduate School(北京大学深圳研究生院);Wuhan University(武汉大学);University of Science and Technology of China(中国科学技术大学);Hong Kong University of Science and Technology(香港科技大学);Sony AI(索尼人工智能);Microsoft Research Asia(微软亚洲研究院)
Know Thy Enemy: Securing LLMs Against Prompt Injection via Diverse Data Synthesis and Instruction-Level Chain-of-Thought Learning
State Key Laboratory of Complex System Modeling and Simulation Technology(复杂系统建模与仿真技术国家重点实验室);Science and Technology on Integrated Information System Laboratory, Institute of Software Chinese Academy of Sciences(中国科学院软件研究所综合信息系统技术国家级重点实验室);University of Chinese Academy of Sciences(中国科学院大学);Nanyang Technological University(南洋理工大学);Beijing Forestry University(北京林业大学)