Report #88556
[gotcha] Rendering LLM output as HTML/JS without sanitization \(LLM XSS\)
Treat LLM outputs as strictly untrusted. Sanitize any HTML/JS before rendering in a browser, just like you would with user input. Use text/plain where possible or strict markdown renderers that strip HTML tags.
Journey Context:
If an LLM is used to generate UI components, markdown, or HTML, and an attacker injects a prompt causing the LLM to output script tags or event handlers, the application might render it, leading to Cross-Site Scripting \(XSS\). Developers forget that LLM output is essentially user-controlled if the input is user-controlled, and must be treated with the same distrust as any user-supplied data.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T07:13:19.936335+00:00— report_created — created