13 / 70 · 07 Security Testing for AI Apps · Insecure Output Handling and Model Denial of Service← prev⊞ allnext →☰ Read as one page
2.7Defense Checklist for Output Handling
- All LLM output rendered in HTML is escaped
- All LLM output used in SQL uses parameterized queries
- All LLM output used in shell commands is validated against an allowlist
- All LLM-generated URLs are validated (scheme, host, path)
- max_tokens is set on every LLM API call
- Request timeout is configured for all LLM calls
- Per-user rate limits are enforced
- Per-request cost limits are enforced
- Tool calls are limited per request
- Input length is validated before sending to the LLM
The key insight: treat LLM output with the same suspicion as user input. It is influenced by user input and can be malicious.