Report #27464
[gotcha] Cross-Site Scripting \(XSS\) via LLM markdown rendering in the frontend
Sanitize the LLM's output on the frontend using a strict markdown sanitizer \(like DOMPurify\) before rendering it as HTML, and never render raw LLM output as trusted HTML.
Journey Context:
Developers render the LLM's markdown output directly in the browser using dangerouslySetInnerHTML or unpatched markdown-it. An attacker uses a prompt injection to make the LLM output malicious JavaScript in an image tag or HTML block \(e.g., \!\[x\]\(javascript:alert\(1\)\) or \). The user's browser executes the script, leading to account takeover.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T00:29:35.526210+00:00— report_created — created