LlamaFirewall
Meta's open-source guardrail framework for agents that chains scanners for prompt injection, goal hijacking and insecure generated code.
Tags
Description
Scanners: PromptGuard 2 (jailbreak/injection classifier), AlignmentCheck (chain-of-thought audit for goal hijacking and indirect injection), regex/custom LLM scanners, and CodeShield (Semgrep and regex rules across 8 languages). pip install llamafirewall (PyPI 1.0.3, May 2025; Python 3.10+); some scanners need access to gated Llama models on Hugging Face. MIT per LlamaFirewall/LICENSE. Known issue (checked 2026-11-04): with huggingface_hub 1.x or later, importing the PromptGuard scanner from PyPI 1.0.3 fails with “cannot import name 'HfFolder'”. Commit 9a3d175 (2026-03-26) fixed promptguard_utils.py on main but is unreleased, and cli/configure.py on main still imports HfFolder, so llamafirewall configure still breaks. Workaround: pip install "huggingface_hub<1.0" "transformers<5".
Related
- Llama Prompt Guard 2: Meta's small open-weight classifiers (86M and 22M) that flag prompt injection and jailbreak attempts in user input and untrusted content.
- Llama Guard: Meta's open-weight safety classifiers that label LLM prompts and responses as safe or unsafe against the MLCommons hazard taxonomy.
- Invariant Guardrails: Rule-based guardrails that sit between an agent and its MCP servers or LLM provider, checking and blocking tool calls and messages.
- NeMo Guardrails: NVIDIA's open-source toolkit for adding programmable guardrails to LLM-based conversational systems.
Guides & comparisons
- Screen tool and web output for prompt injection before your agent reads it (Guide): Put a check between untrusted tool results and the model: Llama Prompt Guard 2 for injection attempts, LlamaFirewall's scanners for hidden text and generated code, and Llama Guard for content safety. Includes a tested screening wrapper and the limits of each layer.
Sources
- https://github.com/meta-llama/PurpleLlama/tree/main/LlamaFirewall
- https://github.com/meta-llama/PurpleLlama/blob/main/LlamaFirewall/LICENSE
- https://pypi.org/project/llamafirewall/
- https://meta-llama.github.io/PurpleLlama/LlamaFirewall/
- https://github.com/meta-llama/PurpleLlama/commit/9a3d175
Machine-readable
- JSON
- Markdown
- Source file on GitHub (edit via pull request)