Skip to main content

Oct 31, 2026

Improper Output Handling: The OWASP LLM Risk Explained

Improper output handling lets model output reach browsers, databases and shells unchecked. See which controls belong at each downstream sink.

Key Insights

OWASP's Top 10 for LLM Applications 2026 lists Improper Output Handling as LLM10, down from LLM05 in the 2025 edition.

OWASP's governing rule for LLM10 is to treat model output as untrusted input and validate it before any backend function.

MITRE's CWE-79 covers cross-site scripting, and CWE-89 covers SQL injection, two common sinks for model output.

OWASP's LLM10 entry calls for disabling auto-rendering of Markdown images and link previews by default.

The OWASP GenAI Security Project's Top 10 for LLM Applications 2026, published in August 2026, widened improper output handling to cover remote code execution and privilege escalation. Improper output handling occurs when an application passes model text downstream without validating or encoding it. Anyone who can steer the model, often through prompt injection, can then reach whatever consumes that text.

Every destination treats that text differently. A browser renders it as markup, a database executes it as a query, and an agent turns it into a tool call, each one acting before a person reviews anything.

The attacks that follow include cross-site scripting (XSS), SQL injection, command execution, server-side request forgery (SSRF) and data exfiltration through rendered links. This guide covers how each path works and the control that belongs at each sink.

What Is Improper Output Handling?

OWASP defines improper output handling as insufficient validation, sanitization and handling of large language model (LLM) output before an application passes it downstream, a definition carried from 2025 into 2026. The flaw sits in application code, not in the model. The governing rule is to treat model output as untrusted user input and validate it before it reaches any backend function.

The vulnerability appears when code hands model text to an interpreter that treats it as instructions: a browser rendering HTML, a database executing SQL, a shell or eval call, or a tool that writes files. Because prompt input can control model output, the flaw effectively gives users indirect access to additional functionality. The 2026 entry extends that list to terminal, log and IDE sinks, which render control characters without neutralizing them.

Why Does Improper Output Handling Matter for LLM Applications and Agents?

Improper output handling still matters because agents automatically pass model output to tools, and every new integration adds another system that trusts what the model writes. The entry began as LLM02 Insecure Output Handling in 2023, became LLM05:2025, and now sits at LLM10:2026, the furthest fall in the 2026 list.

The entry draws tighter boundaries too, which keep the category from absorbing adjacent problems:

  • Validation of model inputs belongs to LLM01:2026 Prompt Injection.

  • Incorrect or misleading output belongs to LLM07:2026 Misinformation.

Both boundaries keep the entry pointed at the sink rather than at the model. The agentic applications risk list routes its unexpected code execution entry to the same mitigations.

How Do Attackers Exploit Improper Output Handling?

Attackers exploit improper output handling by steering the model, often through indirect prompt injection in an email or document it reads, until its output carries a payload that a downstream sink renders or executes. The model needs no compromise; it only needs to repeat what the attacker planted. Which sink receives that text decides what the payload becomes.

Model output fans out to four sinks, labeled browser cross-site scripting, database SQL injection, agent tool call unsafe action, and chat renderer data exfiltration.

Cross-Site Scripting Through Generated Content

An interface that inserts model output into a page as HTML hands the browser whatever the model wrote, script included. The common case is JavaScript or Markdown written by the model and interpreted by the browser, and the pattern repeats wherever generated text is rendered later, including support tickets and chat transcripts.

MITRE's Common Weakness Enumeration catalog classifies it as CWE-79, cross-site scripting, improper neutralization of input during web page generation. In front-end code, the difference between vulnerable and fixed rendering is often a single property: assigning a model reply to an element's innerHTML lets an injected script tag run in the viewer's browser, while textContent displays the same payload as harmless characters.

Injection Through Generated Queries and Commands

Application code that executes what the model wrote inherits whatever an attacker steered it into writing. Generated SQL run without parameterization produces classic SQL injection attacks, which MITRE's catalog lists as CWE-89. Model output passed to a shell, exec or eval produces remote code execution. The interpreter cannot tell a legitimate query from an injected one, because both arrive as text through the same path.

Researchers Tong Liu and colleagues ran attacks against 17 LLM-integrated apps in the LLMSmith vulnerability study and found 16 of them vulnerable to remote code execution. A helper that evaluates expressions the model supplies, such as a math or code tool, is a recurring path to that result.

Unsafe Tool Calls by AI Agents

An agent makes the sink an action rather than a page or a query because it converts model output into function or Model Context Protocol (MCP) arguments and calls the tool before anyone reads them. Tools that fetch URLs from those parameters can be steered toward internal services such as cloud metadata endpoints, which is SSRF.

File writes carry the same exposure. An agent able to write to its own configuration can be steered into disabling its confirmation prompt, after which later tool calls run unchecked. Excess privileges raise the impact of such a flaw to privilege escalation, the same root cause behind excessive agency in LLMs.

Rendering becomes the exfiltration step when a chat interface auto-renders Markdown images or link previews, because conversation data can leave through the image URL's hostname or query string.

An assistant that reads email or documents can be steered into composing such an image, and the fetch happens as the page renders, with no click from the reader. Retrieval-augmented generation (RAG) widens the exposure, since planted text only has to reach what the model retrieves.

The 2026 entry's answer at this sink is to stop model output from triggering automatic outbound requests: disable auto-rendering of Markdown images and link previews by default, or limit fetches to an allowlist or a server-side proxy. Generated links also carry phishing payloads into email templates.

How Is Improper Output Handling Different from Prompt Injection?

Prompt injection is how an attacker steers the model; improper output handling is where that steering causes damage. A prompt injection attack changes what the model says, through direct input or indirect content such as emails and documents. Improper output handling describes what the application then does with that text, and OWASP keeps the two as separate entries.

Prompt injection sits at the input boundary, the model in the middle, improper output handling at the output boundary, then the application, with controls feeding the output boundary.

The two appear together in most real incidents: an injected email does damage only when something renders or executes what the model then writes, and many documented prompt injection attack examples end at an output sink. Controls at the sink limit the damage even when the injection itself lands. Effective defenses therefore sit downstream of the model rather than inside it.

How Can Teams Defend Against Improper Output Handling?

Teams defend against improper output handling by placing controls at each sink that consumes model output, because no single filter on the model makes its text safe for every destination.

Treat Model Output as Untrusted Input

Existing input-handling code already does most of this work. The validation and sanitization an application applies to form input covers model responses too, and the review checklists extend with it. OWASP's entry adds control characters to that list: strip ANSI escape sequences before output reaches a terminal or a log, or encode them so they display rather than execute.

A reviewer can trace every place a model response leaves the client and confirm it passes the same validators as a form field. Monitoring output surfaces exploitation patterns downstream, and a log that records the receiving sink serves an investigator best.

Encode Output for Its Destination

Browsers parse HTML, JavaScript, URLs and CSS differently, and OWASP's Cross Site Scripting Prevention Cheat Sheet sets one rule for all untrusted data: encode for the context the text lands in. The 2026 entry calls for the same context-aware approach.

Text in an HTML body gets entity encoding, attribute values get attribute encoding and quotes, and URLs in href or src attributes are validated against an http and https allowlist. Rendered Markdown becomes HTML, which puts it under the cheat sheet's guidance for user-authored HTML: a maintained sanitizer, patched regularly. Content Security Policy restricts inline and remote scripts as defense in depth.

Validate Against Schemas and Allowlists

A schema narrows what model output can express before code acts on it: an expected JSON response passes validation only when the required fields are present, and no extraneous properties appear. Tool calls follow the same logic, with an allowlist of permitted tools, parameters and URL destinations checked by deterministic code.

For databases, the Query Parameterization Cheat Sheet names server-side parameterized queries as the best defense against SQL injection. A model can still choose values, but bound parameters do not alter the query's structure. Table names and sort order cannot be parameterized, and those choices map to fixed, application-owned values.

Limit and Approve What Output Can Execute

Encoding and validation both miss payloads sometimes, and containment then decides how far executed code can reach. Production agents can bar eval outright, run generated code as an unprivileged user rather than root, and execute it inside a container with strict limits, including network access. Egress allowlists shrink the reach of SSRF, and least privilege applies to every consuming service: a reporting agent's database role can be read-only, scoped to one tool.

Approval puts a person between model output and irreversible change. Destructive actions such as delete, transfer and publish can require human confirmation, ideally with a diff preview, while authorization stays in downstream systems rather than in the model's judgment. Red teams can then plant XSS, SQL and URL payloads in documents the model reads and inspect each sink for execution or outbound requests.

Every Sink Earns Its Own Control

The defenses that carry weight sit at the sinks: context-aware encoding where output is rendered, parameterized queries and schema checks where it is executed, least privilege around whatever runs it, and human approval before anything irreversible. None of them depends on the model behaving. Teams shipping an LLM feature can list every place model output leaves the application and name the control standing between that text and the system it reaches.

Frequently Asked Questions

What is improper output handling in OWASP?

Improper output handling is OWASP's name for applications that pass large language model output to browsers, databases, shells or tools without adequate validation, sanitization or encoding. The 2026 list numbers it LLM10, down from LLM05 in 2025 and LLM02 Insecure Output Handling in the original 2023 list.

What is an example of improper output handling?

A support chatbot that inserts its replies into a web page as raw HTML is a typical example. An attacker hides an instruction in a document the bot reads, the model returns a script tag, and the visitor's browser runs it. The same flaw appears when generated SQL runs without parameters.

How do you prevent improper output handling in LLM applications?

Teams reduce the risk by treating model output as untrusted input and controlling each sink. That means context-aware encoding for HTML and URLs, parameterized queries for databases, schema and allowlist checks for tool calls, sandboxing and least privilege for anything that executes, and human approval for destructive actions.

Is improper output handling the same as prompt injection?

No, prompt injection is how an attacker steers what a model says, while improper output handling is the application flaw that lets that text cause harm downstream. OWASP lists them as separate entries. The two usually appear together in one incident chain.

Why did improper output handling drop in the 2026 OWASP list?

The entry fell the furthest of any in the 2026 edition, from fifth to tenth. The drop reflects a reordering of the whole list rather than a narrower flaw, and the same mitigations still apply wherever an application acts on model output.

Protect Against Evolving Email Threats

See how behavioral AI detects attacks that legacy defenses miss.