Retrained AI model resisted most hidden commands in agent tests
SecPO: Principled Adversarial Training for Prompt Injection Security
TL;DR With 800 tries per task, an attacker AI hijacked the team’s model on 8.8% of tool-using tasks, versus 78.8% for the best earlier defense. Hidden commands in emails are a top threat to AI that acts for users, and the model kept its everyday skills.
Words to know
- AI agent
- An AI system that takes actions for a user, such as sending email or running code.
- prompt injection
- A hidden command placed in text an AI reads, meant to make it obey an attacker instead of the user.
- adversarial training
- Training an AI on deliberately hard attacks so it learns to resist them.
The problem
An AI agent acts for you and reads email, files and websites. An attacker can hide a command there, called a prompt injection. In one real case, a coding agent read a GitHub issue with a specially written title and ran the attacker’s code. The best earlier defense, Meta-SecAlign, keeps the model close to its original behavior to protect its skills. But the original obeys planted commands, and strong attacks still broke the defense nearly every time.
The idea
The team changed what the model learns to imitate. Picture a trainer who plants forged notes in a new clerk’s files. The old rule said to copy a veteran clerk, the original model, who obeys forged notes. The new rule says to copy the veteran reading the clean file, which the trainer kept. They also used adversarial training: an attacker AI rewrote each planted command many times, keeping the version that best fooled the model. A small Llama model faced live attacks; a larger Qwen model reused the saved ones. The authors argue the old target pulled the model toward obeying, and the new one does not.
What they showed
- Far fewer hijacks on agent tasks. With the larger Qwen model, the attacker won on 8.8% of AgentDojo tasks, a set of chores for tool-using agents. Meta-SecAlign on the same model lost 78.8% of them.
- Both changes count. On simple instruction tasks with the small Llama model, hard training attacks with the old target still let the attacker win on 29.2% of tasks. Switching to the new target cut that to 12.3%.
- Skills kept, against new attackers. Averaged over tests of knowledge, math and following instructions, the team’s Qwen model scored about the same as the original. The test attackers also differed from the one used in training.
Why it matters
Teams that build AI agents for email, coding or shopping could train them this way, if the results hold. The change to the training method is small, and the code and trained model are public. The attack search is costly, but saved attacks let others skip it. For you, an agent reading a stranger’s email would more often ignore orders hidden there.
The catch
The headline agent number comes from only 80 tasks, so it could be off by several points in either direction. The defense also assumes the agent is told which text is trusted. If that label is missing, the method does not apply. The team turned off the model’s step-by-step thinking mode, so reasoning models are untested. The authors also warn that stronger future attacks may still beat it.
Who wrote it
Sizhe Chen is first of five authors. Four, including Chen and David Wagner, are at UC Berkeley. Chawin Sitawarin is at Anthropic and did this work at Google DeepMind. The paper is a preprint, not yet peer reviewed.