Report #42240
[gotcha] LLM generating markdown or HTML that executes XSS when rendered in the frontend
Treat LLM output as strictly untrusted user input. Use a sandboxed markdown renderer \(like DOMPurify\) that strips HTML tags, script events, and dangerous attributes before injecting into the DOM.
Journey Context:
If an LLM is fed untrusted data \(e.g., a web page summarizer\), an attacker can inject \`\` into the source. The LLM might faithfully reproduce this in its output. If the frontend renders this markdown/HTML directly, it results in XSS. Developers often implicitly trust the LLM's output because they wrote the system prompt, forgetting the LLM is a proxy for untrusted input.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T01:22:24.363484+00:00— report_created — created