Prompt injection defence learns from the clean input
Reviewing SecPO: Principled Adversarial Training for Prompt Injection Security · Sizhe Chen, Yibo Peng, Jaewon Chang et al.

Researchers find that the leading model-level prompt injection defence is trained to stay close to an insecure model. Anchoring instead to how the model answers the clean input, and training against strong attacks, cuts adaptive hijacking sharply in agent workflows without hurting utility. That makes successful attacks slower and more expensive.
The best published model-level defence against prompt injection has a quiet flaw. Under adaptive attacks, where the attacker keeps rewriting the injection until it lands, it is hijacked close to every time. This research explains part of why. The reason is in how the defence was trained.
These defences fine-tune a model to prefer the safe answer when an email, document or web page carries hidden instructions. The training method rewards the preferred answer. It also pulls the model back towards a reference model, so it does not drift and lose its usefulness. That reference is the original, undefended model. It is the model that follows injected instructions.
So the defence is tethered to the thing it is meant to replace. Every training step nudges towards safety while the anchor pulls back towards obedience.
The clever part is noticing that the ideal anchor is already within reach. You want a model that answers an injected input exactly as it would answer the same input with the injection removed. In training you have both versions, because you built each injected sample from a clean one. So the researchers query the undefended model on the clean input and anchor to that. The model is pulled towards being useful, not towards obeying the attacker.
The second fix is less elegant and matters as much. The earlier defence trained on weak, simulated injections. Here the researchers run an automated search that makes hundreds of attempts per example, then train against the injections that worked. Training on strong attacks did much of the work. The new anchor cut success rates by a further two to four times or so.
In agent workflows the difference is large. Against one strong adaptive attack, the defended model was hijacked 8.8% of the time, against 78.8% for the previous best defence. Utility across nine benchmarks barely moved. I give this real weight because it was measured against attackers adapting to the defence, which is the test that matters.
The limits are stated plainly. The model is told which inputs are trusted and which are not; if your agent cannot label its inputs, this does not apply. Reasoning was switched off for some evaluations, and securing reasoning models is left for later. The attacks that still landed were mostly social engineering: instructions that look necessary for the task, or split across several fields or steps.
That residue is where an attacker should look next. Successful attacks also needed roughly twice the queries and about six times the cost. What surprised me is how much came from fixing the anchor and the sparring partner rather than the architecture. Prompt injection is not solved. It is more expensive.
Further analysis
Problem
This paper studies prompt injection attacks that embed attacker instructions inside untrusted inputs (emails, documents, websites) to manipulate agentic large language models. Prompt injections are identified as a top practical threat because agents regularly consume untrusted context and may follow malicious instructions. Prior model-level defences anchor fine-tuning to an undefended reference model and train on weak simulated attacks; the result is high attack success rates under stronger adaptive attacks.
Approach
The authors propose Secure Preference Optimization (SecPO), a principled modification of direct preference optimisation. SecPO replaces the insecure reference anchoring by an idealised oracle that is injection-invariant yet utility-preserving; in practice the oracle’s output distribution on injected inputs is approximated by querying the undefended model on the corresponding clean inputs. SecPO therefore regularises towards the undefended model’s clean-input outputs rather than its behaviour on injected inputs, emphasising samples where injections shift the undefended model’s preferences. SecPO is paired with adversarial training (AT) that synthesises strong adaptive injections using a parallelised search-based attack pipeline (PAIR) with 240 trials per example. The authors fine-tune Llama-3.1-8B-Instruct with online AT and produce an offline corpus of optimised injections that they use to fine-tune Qwen3.6-27B. They evaluate on multiple held-out adaptive attacks and on nine benchmarks covering instruction following, agentic tool use, science and maths, and visual injections. They release code, the optimised training data and defended model checkpoints.
Key Findings
- Adversarial training alone reduces attack success rates by 1.5–14.5× across three state‑of‑the‑art adaptive attacks relative to the prior DPO-based defence.
- Replacing DPO with SecPO yields an additional 2.4–4.6× reduction in attack success rates under the same AT regime.
- On agentic evaluation, SecPO+AT Qwen3.6-27B achieves 8.8% ASR@800 under a strong adaptive attack versus 78.8% for Meta‑SecAlign; the maximum ASR of three adaptive attacks is 13.3% for the defended model versus 94.0% for Meta‑SecAlign.
- On a challenging real-world agentic benchmark (DTaP-Bench), the defended model attains 7.6% ASR while maintaining benign utility; mean utility measures change negligibly (for example, Llama variants show mean utility around 47% and Qwen around 89%).
- Security from textual AT transfers to adaptive visual prompt attacks in their tests: their defended Qwen model had 0% ASR on evaluated visual attacks while retaining high benign visual utility.
- The defended model raises attack cost for successful attacks: mean victim queries and monetary cost conditioned on success increased by about 2.08× and 5.90× respectively.
Limitations
The threat model assumes agents are given explicit labels for trusted versus untrusted inputs and excludes cases where the user is malicious or trust labels are unknown. Experiments focused on non‑reasoning settings or disabled chain‑of‑thought “thinking” for some evaluations; securing reasoning models remains future work. Generating strong adaptive attacks is computationally expensive and constrained the breadth of hyperparameter exploration. The authors acknowledge that stronger future attacks may still succeed and that social‑engineering style injections remain a challenging class.
Implications
Offensively, attackers can adapt by using social engineering and semantically subtle instructions that appear necessary for a task, distribute malicious instructions across multiple fields or steps, or embed misleading benign‑looking information to expand an agent’s workflow. Such patterns were responsible for many remaining successful attacks against the defended model. The work shows that substantial increases in attacker effort and cost are required to achieve success against SecPO+AT models, meaning resourceful adversaries may still succeed but at higher operational cost. The released attack and training artefacts also enable red‑teamers and researchers to evaluate and evolve attacks against defended systems.
The paper title, authors and abstract
SecPO: Principled Adversarial Training for Prompt Injection Security
Recognized as a top threat to AI agents, prompt injection allows instructions from untrusted data (email, documents, websites) to manipulate the agent's operation. The existing best-defended LLM, Meta-SecAlign, is trained with the DPO loss but still suffers from attack success rates (ASRs) approaching 100% under adaptive prompt injections. One reason is that DPO anchors the model around the undefended reference model, which is insecure. We show an idealized reference model---an injection-invariant, utility-preserving oracle---can nevertheless be approximated, as its output distribution in training is interestingly accessible. This new observation motivates a theoretically principled SecPO loss. Another Meta-SecAlign shortcoming is that it trains on weak simulated attacks. We implement an efficient adversarial training (AT) pipeline that synthesizes strong injected inputs (best@240), and train the model on them. Our AT reduces ASRs by 1.5-14.5$\times$ across three SoTA adaptive attacks, compared with Meta-SecAlign; the SecPO loss reduces them by a further 2.4-4.6$\times$ compared with using DPO loss. In agentic workflows, our SecPO + AT Qwen3.6-27B is much more secure than Meta-SecAlign: 8.8% vs. 78.8% AgentDojo ASR@800 under the AttackerMovesSecond attack. Moreover, our defended model shows no noticeable reduction in benign utility in nine benchmarks covering agentic tool calling, instruction following, science, and math. We release our $\href{//github.com/Sizhe-Chen/SecPO}{\text{code}}$, $\href{//huggingface.co/datasets/Sizhe-Chen/Qwen3.6-27B-Instruct-SecPO-trainset}{\text{training data}}$ (with optimized injections from AT), and $\href{//huggingface.co/Sizhe-Chen/Qwen3.6-27B-Instruct-SecPO}{\text{model}}$.


