GO TO A SECTION

↑ ↓ to navigate · Enter to openExplore all sections →
FDEInterviews logo
arXiv preprint

LlamaFirewall: An Open Source Guardrail System for Building Secure AI Agents

Meta's open-source agent guardrails: a jailbreak classifier on inputs, an LLM auditing the agent's reasoning, static analysis on code. Together they cut AgentDojo attack success from 17.6% to 1.75%.

Breakdown by FDE Interviews · 12 min read · Updated

About the original · 2025
AUTHORS
Chennabasappa, Nikolaidis, Song, Molnar, et al.
FROM
Meta
PUBLISHED
May 2025 · arXiv preprint
IN THIS BREAKDOWN · 10 SECTIONS

You can read 17% of this breakdown.

01

The paper in one minute

LlamaFirewall is an open-source framework from Meta for putting security checks around an LLM agent, and it is used in production there. It ships three guardrails, each aimed at a failure that shows up at a different point in the agent loop.

PromptGuard 2 is a small classifier (mDeBERTa-base, 86M parameters, or DeBERTa-xsmall, 22M) that scans user input and tool output for explicit jailbreak techniques such as instruction overrides and role reassignment. Its scope was deliberately narrowed from PromptGuard 1, which tried to detect goal hijacking in general and produced too many false positives. On a private out-of-distribution set it detects 97.5% of jailbreaks at a 1% false-positive rate, against 21.2% for PromptGuard 1.

AlignmentCheck is a large LLM (Llama 4 Maverick or Llama 3.3 70B), prompted few-shot, that reads the agent's reasoning and its selected action and asks whether they still serve the user's original goal. It catches injections that contain no jailbreak phrasing at all, which a lexical classifier misses. The authors label it experimental.

CodeShield is static analysis (Semgrep and regex rules covering more than 50 CWEs) for code written by coding agents. Most scans finish in about 60 ms; roughly 10% go to a slower second tier.

On AgentDojo, replaying static traces from ten agent models, attack success fell from 17.6% to 7.5% with PromptGuard 2, to 2.9% with AlignmentCheck, and to 1.75% with both. Utility fell from 47.7% to 42.7%.

THE IDEA, VISUALLY
SCANNERS IN THE AGENT LOOP (SECTION 3) User input + tool output PromptGuard 2 86M / 22M classifier context flagged → page dropped from context Agent reasons + selects action AlignmentCheck LLM vs user goal tool call flagged → execution halted Code output coding agents CodeShield Semgrep + regex commit insecure → patch rejected, agent retries WHAT EACH ONE SEES PromptGuard: explicit jailbreak phrasing, user and tool roles AlignmentCheck: assistant messages only, never raw tool output, so the auditor is harder to inject CodeShield: the code diff, 50+ CWEs Open source (PurpleLlama); used in production at Meta. AlignmentCheck is labeled experimental by the authors. AGENTDOJO, STATIC TRACES OF 10 MODELS (4.3) attack success % utility % no guardrail 17.63 47.7 PromptGuard 2 86M 7.53 47.0 AlignmentCheck 2.89 43.1 both 1.75 42.7 if independent, both would give 1.23%: the layers overlap PROMPTGUARD, PRIVATE OOD JAILBREAK SET (TABLE) recall at 1% false positives latency, A100 PromptGuard 1 21.2% 92.4 ms PG 2 86M 97.5% 92.4 ms PG 2 22M 88.7% 19.3 ms CODESHIELD (4.4) precision 96%, recall 79% on 50 labeled completions per language (CyberSecEval 3) tier 1 ~60 ms; ~10% escalated to a ~300 ms tier At a 1% false positive rate and 1 injection in 1,000 inputs, about 9 in 10 PromptGuard flags are benign (ours).
Three scanners at three points in the loop, each with its own response: drop the page, halt the action, reject the patch. Layered, they cut AgentDojo attack success by 90% for a 5-point utility cost.
Research notes: the problem, approach and results
17.6% → 1.75%

AgentDojo attack success with PromptGuard 2 and AlignmentCheck combined, utility 47.7% → 42.7%

97.5%

PromptGuard 2 86M recall at 1% false positives on a private jailbreak set (PromptGuard 1: 21.2%)

96% / 79%

CodeShield precision and recall for insecure code, at about 60 ms for most scans

THE PROBLEM

Agents act on untrusted web pages, emails and code, and chatbot-style moderation doesn't cover prompt injection against permissioned agents, goal hijacking or insecure generated code.

THE IDEA

A policy engine that runs specialized scanners where each failure is visible: PromptGuard 2 (a 22M or 86M DeBERTa classifier) on user and tool text, AlignmentCheck (a large LLM prompted few-shot) on the agent's reasoning and next action, and CodeShield (Semgrep and regex rules) on generated code.

THE RESULT

On AgentDojo traces of ten models, attack success fell from 17.6% to 7.5% with PromptGuard 2, 2.9% with AlignmentCheck and 1.75% with both, while utility fell from 47.7% to 42.7%. PromptGuard 2 86M caught 97.5% of out-of-distribution jailbreaks at a 1% false-positive rate.

02

Why it matters to an FDE

The useful idea here isn't any single model. It's that a guardrail is defined by where it sits and what the orchestrator does when it fires. Dropping a suspicious web page from context, halting before a tool call and rejecting a code patch are three different responses, and each matches a different failure.

It gives you a layered design you can copy. A cheap classifier filters the obvious attacks on every input; an expensive auditor runs on the decisions that matter; deterministic rules check the artifacts. The paper reports latency and false positives for each, which is what a customer's platform team will ask about first.

It is honest about what's experimental. AlignmentCheck works best with a very large model, adds substantial latency and can itself be targeted by injection. The paper's own limitations section says so, and those are the trade-offs you will negotiate on a deployment.

It's open source. The code is in Meta's PurpleLlama repository, so a team can run the same scanners on its own traffic before trusting any number in the paper.

THE FULL BREAKDOWN

Understand the mechanism. Try it on a real problem.

Unlock this breakdown and 157 more papers.

Premium opens every paper in full, plus every answer, concept, course and guide on the site. One payment for six months of access.

6 months · One payment · No auto-renewal

Get Premium · ₹2,000 / $25
  • ◇1 architecture diagram
  • </>1 runnable code experiment
  • ▦2 results tables
  • ?5 interview questions with answers
  1. 03Key takeaways

    Scope, placement, the AgentDojo trade-off, the costs of an LLM auditor and three misreadings

    Free account
  2. 04How it works

    Two worked scenarios, PromptGuard 2's training, AlignmentCheck's inputs, the evaluation method

    Premium
  3. 05The numbers that matter

    AgentDojo trade-offs, PromptGuard 2 operating points, AlignmentCheck and CodeShield accuracy

    Premium
  4. 06Try it yourself

    Recompute the AgentDojo trade-offs, price the code scanner, and test base rates and flag timing

    Premium
  5. 07Where it breaks

    Narrow evaluation, offline scoring, the auditor's cost and attack surface, and the paper's slips

    Premium
  6. 08Using it on a deployment

    Where each check goes, what happens on a hit, thresholds from your traffic, the latency budget

    Premium
  7. 09Interview angles

    Five questions this paper prepares you for, with answer hints

    Premium
Back to the paper library →