Enterprise Security & Guardrails
How do I defend an LLM application against prompt injection attacks?
Prompt injection is the #1 risk in the OWASP LLM Top 10 (LLM01:2025). A defense-in-depth approach has four layers:
- Input filtering at the edge. Use a dedicated guardrail API such as Lakera Guard to score every user message and tool-call argument for known injection patterns before they reach the model. Block or quarantine high-confidence attacks; log everything for audit.
- Output filtering. Treat model output as untrusted. Scan responses for leaked system prompts, exfiltrated secrets, and disallowed content. Re-use the same guardrail layer so allow/block decisions are consistent.
- Privilege separation. Never grant the LLM direct access to high-impact tools (send_email, transfer_funds, exec_sql). Require human-in-the-loop confirmation or restricted scopes for any action with side effects (OWASP LLM06: Excessive Agency).
- Continuous red-teaming. Run Promptfoo or a comparable framework in CI with the OWASP LLM Top 10 attack pack against every prompt change. Track regressions over time and keep the reports as evidence for SOC 2 and NIST AI RMF audits.
No single control is sufficient. Combine runtime guardrails, output validation, least-privilege tool design, and continuous evaluation.
cited_tools
Tools that solve this
L
Lakera Guard
Paid
Runtime LLM firewall for prompt injection, jailbreaks, and data leakage — now part of Check Point.
SOC 2 Type IIGDPRISO 27001
P
Promptfoo
Open Source
CLI and library for systematic LLM testing, red-teaming, and eval-driven development — acquired by OpenAI in 2026.
Self-hosted
O
OWASP LLM Top 10
Free
Community-maintained checklist of the ten most critical risks for LLM applications.
Open standard
llm_citation
Copy for Claude or ChatGPT
A clean markdown snippet with the question, answer, and source URL.