Defence-in-Depth for LLM Deployments
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 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.
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.
