Skip to content

Meta-SecAlign: Training LLMs against Prompt Injection for Robust Agents

Jul 2025 · 0 citations · 66 references
Computer Science

TL;DR

Meta-SecAlign is proposed for utility-preserving defense by (1) randomized injection position during training to avoid shortcut learning and (2) self-generated responses as high-quality in-distribution training labels as high-quality in-distribution training labels.

Abstract

Prompt injection attacks, where untrusted data contains an injected prompt to manipulate the system, have been listed as the top security threat to AI agents. By fine-tuning on simulated prompt injections, SecAlign, a leading open defense, reports LLMs with good test-time robustness and negligible benign utility drop. By scaling up training and evaluations, however, we find that SecAlign actually suffers from significant utility degradation, especially in agentic tasks where the threat of prompt injection is prominent. Motivated by this, we propose Meta-SecAlign for utility-preserving defense by (1) randomized injection position during training to avoid shortcut learning and (2) self-generated responses as high-quality in-distribution training labels. Across general knowledge, instruction following, and agentic workflows (on tool-calling and web-navigation), Meta-SecAlign maintains almost all the undefended LLM's utility while achieving better overall security than SecAlign against various static and GCG adaptive attacks. Experiments use Llama-3.1-8B, Llama-3.3-70B, Llama-4-Scout, Qwen3-4B, and Qwen3.6-27B on 6 prompt injection benchmarks including AgentDojo, InjecAgent, WASP, and SEP. Below are links for the code (https://github.com/facebookresearch/Meta_SecAlign), Meta-SecAlign-70B (https://huggingface.co/facebook/Meta-SecAlign-70B), and Meta-SecAlign-8B (https://huggingface.co/facebook/Meta-SecAlign-8B) models.

View source

Similar papers

#artificial intelligence Preprint Oct 2026

SecPO: Principled Adversarial Training for Prompt Injection Security

An idealized reference model---an injection-invariant, utility-preserving oracle---can nevertheless be approximated, as its output distribution in training is interestingly accessible, which motivates a theoretically principled SecPO loss.

Si-Zhe Chen, Yi-Bo Peng, Jaewon Chang et al. · 2 citations
#machine learning Preprint Oct 2026

Heads of Security: Learned Attention Gates Improve Prompt Injection Robustness

Heads of Security (HoS), a prompt injection defense that enforces instruction-data separation via a small set of learned per-head attention gates, is introduced and shows that prompt injection robustness can be achieved and improved through targeted attention interventions.

Igor Shilov, Xiao-Xue Yang, Alexander Panfilov et al. · 1 citation
Sep 2026

Self-Evolving Defense: Continual Security Policy Learning for LLM Agents

Large language models (LLMs) increasingly power agents that access sensitive information, use external tools, and modify software repositories. Although these capabilities offer substantial benefits, they also create security risks such as jailbreaks, prompt injection, and vulnerable code generation. Existing defenses...

M. Le, Nisarga Gondi, Yi-Bo Peng et al. · 0 citations

Decoding Guardrails: XAI-Guided Perturbation Analysis of Prompt Injection Detection

An exploratory case study that applies explainable artificial intelligence techniques to analyze how Prompt Guard 2 distinguishes malicious from benign prompts finds that Prompt Guard 2's decisions rely on the cumulative contribution of many tokens rather than a few dominant ones, yet saliency-guided synonym substituti...

Fernando Outeda, Gustavo Betarte, J. Campo et al. · 0 citations

Related blog posts

We use cookies to run the site and, with your consent, for analytics and to show ads. See our Cookie Policy.