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:

  1. 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.
  2. 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.
  3. 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).
  4. 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

3 cited

llm_citation

Copy for Claude or ChatGPT

A clean markdown snippet with the question, answer, and source URL.