Insecure Output Handling
Insecure Output Handling is a vulnerability in which an application uses the output of a large language model, for example by rendering it in a browser, executing it, or passing it to a database, without validating or sanitizing it first. The OWASP Top 10 for LLM Applications lists this risk, named Improper Output Handling in its 2025 edition.
What is Insecure Output Handling?
LLM output can be influenced by users, retrieved documents, and prompt injection, so it should be treated as untrusted input. If an application inserts model output directly into a web page, a shell command, a SQL query, an email template, or another system, an attacker who can shape that output may trigger cross-site scripting (XSS), SQL injection, server-side request forgery, remote code execution, or privilege escalation in downstream components. Markdown and HTML rendering can also be used to send data to external servers, for example through image links.
Why is Insecure Output Handling Important?
Many AI applications focus security efforts on the prompt and overlook what happens to the response. Because output handling connects the model to the rest of the application, a weakness here can turn a prompt injection into a conventional, high-impact web or system vulnerability. Standard defences include encoding and validating output based on where it is used, using parameterized queries, restricting what generated code can run, scanning model output, and applying least privilege to any system the output reaches.
Common use cases
Insecure output handling is relevant to chatbots that render HTML or Markdown, AI features that generate SQL or code, AI agents that execute commands, email and document generation, plugins and tool integrations, and any workflow in which LLM output is consumed by another system.