AI Security
New Defense Method Shields AI Agents from Prompt Injection Without Sacrificing Performance
Researchers propose Meta-SecAlign, a training technique that protects language models from prompt injection attacks while preserving their core capabilities.
Prompt injection attacks—where adversaries embed malicious instructions within untrusted data to manipulate AI systems—represent a critical vulnerability in deployed AI agents. A team of researchers has now introduced Meta-SecAlign, an improved defense approach that maintains language model utility while bolstering security against these threats.
The Problem with Existing Defenses#
The current leading defense, SecAlign, achieves strong performance on test benchmarks by fine-tuning models on simulated prompt injections. However, when researchers scaled up training and evaluation, they uncovered a significant flaw: SecAlign causes substantial performance degradation, particularly for agentic tasks where prompt injection risk is highest. The model learns shortcuts during training that hurt real-world utility.
How Meta-SecAlign Works#
Meta-SecAlign addresses this shortcut learning through two key innovations:
- Randomized injection positions: Rather than injecting prompts at fixed locations during training, the method varies where adversarial instructions appear. This prevents the model from exploiting simple pattern-matching shortcuts.
- Self-generated training labels: The approach uses the model's own high-quality outputs as in-distribution training data, rather than relying on synthetic examples alone.
Together, these techniques allow the model to learn genuine robustness while preserving its original capabilities.
Evaluation Across Multiple Tasks#
The researchers tested Meta-SecAlign on multiple language models—including Llama-3.1-8B, Llama-3.3-70B, Qwen3-4B, and Qwen3.6-27B—across diverse benchmarks such as AgentDojo, InjecAgent, WASP, and SEP. Results show that Meta-SecAlign maintains nearly all of an undefended model's performance on general knowledge, instruction following, and agentic workflows (tool-calling and web navigation) while achieving stronger security than SecAlign against both static and adaptive attacks.
What's Next#
The team has released code and pre-trained models (Meta-SecAlign-70B and Meta-SecAlign-8B) to enable broader adoption and further research into more robust AI agent defenses.

