Seedlabs
Source research

DRIP: Defending Prompt Injection via Token-wise Representation Editing and Residual Fusion

Ruofan Liu, Yun Lin, Zhiyong Huang, Jin Song Dong · 2026 · 6 citationsRead the paper

Large language models (LLMs) are rapidly becoming core components of IT infrastructure, tasked with processing user data according to predefined instructions. However, LLMs remain vulnerable to prompt injection attacks, where malicious users inject directive tokens within the data to manipulate model behavior. The current defense strategies attempt to train LLMs to semantically distinguish between data and instruction tokens. Nevertheless, these approaches still face two key challenges: (1) the balance between security and utility, especially when interpreting the instruction-like tokens in the data section, and (2) the robustness against adaptive adversarial samples. In this work, we propose DRIP which aims to (1) achieve a new security-utility balance by ''de-instructionalization'', i.e., precisely removing the instruction semantics from the tokens in the data section while preserving their data semantics and (2) robustly maintain the effectiveness of the intended instruction, even against strong adversarial content. As for ''de-instructionalize'' tokens in the data section, we propose a training paradigm across data curation, model architecture, and loss design. It introduces a lightweight representation-editing module, which is trained to edit the embedding of instruction-like tokens in the data section, enhancing the model's security without compromising utility. As for preserving the intended instruction against unseen adversarial content, we improve the model architecture by introducing a lightweight residual module in LLM, largely reducing the overwriting possibility of adversarial content. We extensively compare DRIP with state-of-the-art techniques, including StruQ, SecAlign, ISE, and PFT on LLaMA-8B and Mistral-7B across three prompt injection benchmarks (SEP, AlpacaFarm, and InjecAgent). The results show that DRIP (1) improves role separation score by 44–64% and reduces attack success rate by over 68% for adaptive attacks and (2) achieves utility on par with the undefended model, indicating a new state-of-the-art against prompt injection attacks.

What the full text shows

Working prototype
  • Improved role separation between instruction and data semantics. — 44–64% improvement in SEP score (Compared to baselines on LLaMA-8B and Mistral-7B)
  • Reduced attack success rate (ASR) for gradient-based optimization attacks (GCG). — ASR reduced to 1.1% (LLaMA) and 3.4% (Mistral) vs. >66% for baselines (AlpacaFarm benchmark)
  • Maintained instruction-following utility comparable to undefended models. — AlpacaEval 2.0 win rates of 83.89% (LLaMA) and 82.78% (Mistral) vs. 85.37% and 86.39% undefended (AlpacaEval 2.0 benchmark)
  • High adherence to structural and formatting constraints. — IFEval accuracy of 76.02% (LLaMA) and 60.07% (Mistral) (IFEval benchmark)
  • Reduced attack success rate for adaptive attacks. — Over 68% reduction in ASR (General adaptive attacks)
Setup
Evaluated on LLaMA-8B and Mistral-7B using SEP (9,160 tuples), AlpacaFarm (208 examples), and InjecAgent (1,054 test cases) benchmarks.
How
Introduces a token-wise representation-editing module to shift data embeddings away from the instruction manifold and a residual fusion pathway to anchor the original instruction. The system is trained using Direct Preference Optimization (DPO) with a curated dataset covering correct execution, mistaken execution, and instruction-only scenarios.
Limitations
Potential for 'semantic echo' where injected content leaks into the output in an entangled form without overriding the task. · Open-source LMs still struggle with math, reasoning, and coding (specifically Mistral-7B).

Summarized by Gemma 4 from the open-access full text · 19 Nov 2026. Read it