1.4 ยท Prompt Injection & LLM-Specific Threats

Defence-in-Depth for LLM Deployments

โฑ 11 minCourse 01

Secure LLM deployment requires controls at every layer of the stack โ€” not just in the model's system prompt. Here is a layered defence framework applicable to any enterprise LLM deployment.

Layer 1: Input Controls

  • โ—†Input length limits โ€” Unusually long inputs are a common vector for injection attacks; enforce maximum lengths appropriate to your use case
  • โ—†Content classification โ€” Run inputs through a classifier that flags injection attempts before they reach your primary model
  • โ—†Structured input formats โ€” Where possible, accept structured data rather than free text; this dramatically reduces the injection surface
  • โ—†Source verification โ€” For indirect injection scenarios, validate that documents come from trusted sources before processing

Layer 2: Architectural Controls

  • โ—†Privilege separation โ€” The LLM should never have direct access to sensitive systems; all actions should go through a permissions-checked intermediary layer
  • โ—†Minimal permissions โ€” The LLM agent should only have access to what it needs for the specific task; never give an LLM agent admin-level permissions "for convenience"
  • โ—†Human-in-the-loop for high-risk actions โ€” Any action with real-world consequences (sending emails, executing transactions, modifying data) should require human approval
  • โ—†Sandboxed execution โ€” Code generated by LLMs should never execute in the same environment as production systems

Layer 3: Output Controls

  • โ—†Output validation โ€” Check model outputs for patterns that indicate successful injection (unexpected format changes, outputs containing system prompt content)
  • โ—†Data loss prevention on outputs โ€” Scan outputs for sensitive data patterns (email addresses, financial data, credentials) before they reach users
  • โ—†Audit logging โ€” Log all inputs and outputs for post-incident analysis; you cannot investigate what you haven't recorded
The OWASP LLM Top 10

The Open Worldwide Application Security Project publishes an LLM-specific security framework โ€” the OWASP LLM Top 10. It is the most widely referenced security standard for enterprise LLM deployment and covers all the threat categories in this section. We recommend bookmarking owasp.org/www-project-top-10-for-large-language-model-applications.

โœ“ Your Deployment Checklist

Before deploying any LLM-powered tool: (1) Define what the LLM is permitted to do and enforce those permissions structurally; (2) Test it with adversarial inputs before launch; (3) Implement input and output monitoring from day one; (4) Establish a clear process for responding when a jailbreak or injection is reported.