Safeguards: How are the risks reduced? · MarLuc synopsis
Layered guardrails cut AI agent attack success from 17.6% to 1.75% in benchmark tests
PreprintBoth, layered controlControls around the modelMeta researchers describe LlamaFirewall, three guardrails for AI agents, and report that two AI-based checks together cut successful prompt injection in a public benchmark from 17.6% to 1.75%.
Read the research (opens in a new tab)The research at a glance
- Research
- “LlamaFirewall: An open source guardrail system for building secure AI agents”, Sahana Chennabasappa et al.
- Produced by
- Meta (AI company)
- Published
- 6 May 2025
- Evidence
- PreprintPublic research not yet peer-reviewed (for example on arXiv)
- Type of research
- Evaluation
- Control type
- Both, layeredDeterministic and probabilistic controls combined
- Topics
- Controls around the model · Security and attacks
- Checked
- 21 Nov 2026 against the research; independently checked 21 Nov 2026.
Research starting point. Not advice. Each synopsis describes one piece of research in the setting its authors tested; results may not hold for other models, versions or uses. Read the original before relying on it.
1Why it matters
AI agents (AI systems that take actions such as browsing, sending messages or writing code) often read untrusted content such as web pages and emails, and prompt injection (hidden instructions in content an AI reads) can redirect them. The paper asks how far guardrails placed around the agent, rather than training inside the model, can reduce this, and what still gets through. The authors note the absence of deterministic (fixed-rule) solutions for these risks.
2What they did
The authors built an open-source framework with three guardrails and evaluated them separately and together. PromptGuard 2 is a small classifier (an AI model trained to label text) that scans user inputs and tool outputs for jailbreak-style text. AlignmentCheck uses a larger language model to read the agent's reasoning and actions and flag when they drift from the user's goal. CodeShield applies fixed static-analysis rules (pattern and syntax checks on code, without running it) to code that agents write. They measured attack success and task completion ('utility') on AgentDojo, a public prompt-injection benchmark, by replaying recorded runs from ten agent models, and also used Meta's own test sets.
3What they found
As the authors report it, in the setting they tested.
- PromptGuard 2 is probabilistic (a fine-tuned AI classifier, so it can be wrong or fooled). On a private jailbreak test set, the 86M-parameter version detected 97.5% of attacks while flagging 1% of harmless prompts. On AgentDojo it cut attack success from 17.6% to 7.5% with utility almost unchanged (47.7% to 47.0%). What got past: the remaining 7.5% of attacks; the authors say the benchmark covers a narrow class of attacks and that PromptGuard alone may not suffice, for example against an injection that has no jailbreak-style wording.
- AlignmentCheck is probabilistic (a large language model acting as a judge, described by the authors as experimental). On Meta's goal-hijacking benchmark, large models used as the checker detected over 80% of attacks with a false positive rate below 4%. On AgentDojo it cut attack success to 2.89%, but utility fell to 43.1% and checks were much slower. What got past: the remaining attacks; the authors also warn that the checker can itself be targeted by prompt injection, and that smaller checker models blocked many legitimate tasks.
- CodeShield is deterministic (fixed static-analysis rules written in Semgrep and as regular expressions, giving the same result every time). In an earlier evaluation cited by the paper, using 50 manually labelled code completions per language, it identified insecure code with 96% precision and 79% recall, so some insecure code was not flagged; the authors say it "may miss nuanced or context-dependent vulnerabilities".
- Layered together, PromptGuard 2 and AlignmentCheck cut AgentDojo attack success from 17.6% to 1.75%, a reduction of more than 90%, while utility fell from 47.7% to 42.7%.
- The authors report that LlamaFirewall is used in production at Meta, and that in internal deployments about 90% of code scans were completed by CodeShield's fast first layer.
4Limits
What the research does not show, or where its results may not carry over.
- A preprint, not peer-reviewed. The guardrails were built, tested and described by the same Meta team, and AlignmentCheck was tested with Meta's Llama models as the checker.
- The AgentDojo results come from offline replays of recorded runs from ten agent models under one type of injection attack; the authors say this set focuses on a narrow class of attacks. The jailbreak and goal-hijacking test sets are Meta's own.
- CodeShield's accuracy figures come from an earlier paper by overlapping authors, not a new test in this paper, and the paper gives its language coverage as both seven and eight languages.
- The framework also offers custom scanners written as a regular expression (deterministic) or an LLM prompt (probabilistic), but these were not evaluated. Image and audio agents are not yet covered, and the authors list malicious code execution and unsafe tool use as future coverage.
5What it could mean for an organisation
General information, not advice. Whether it applies depends on the systems you build, buy or use.
- Organisations running AI agents on untrusted content face prompt injection risks that, in these tests, no single guardrail removed; the lowest attack success came from layering two AI-based checks.
- The AI-based guardrails traded protection against blocking legitimate work: the paper reports each result at a chosen threshold and utility cost, which an organisation using such tools would need to set for its own tasks.
- Rule-based checks such as CodeShield behave predictably and run fast, but in the cited tests missed some insecure code, so they cover known patterns rather than all flaws.
- An AI-based checker reads the same untrusted material as the agent, so it can be attacked too; the authors limit what AlignmentCheck sees and pre-scan its inputs with PromptGuard.
6Related in MarLuc's libraries
AI governance: NIST AI 100-2, ARIA and Cyber AI Profile · EU CRA · ISO/IEC 42001 · EU AI Act
Sources
- [1]arXiv abstract page, arXiv:2505.03574 (opens in a new tab)The research itself · arxiv.org
- [2]Full paper (arXiv PDF, v1) (opens in a new tab)The research itself · arxiv.org
Checked 21 Nov 2026 · independently checked 21 Nov 2026 · synopsis version 1.0
Spotted an error or newer research? Tell us