Report #75672
[gotcha] Cross-site scripting \(XSS\) via unsanitized LLM output
Treat LLM-generated content as untrusted user input. Apply strict output encoding and sanitization \(e.g., DOMPurify\) before rendering LLM responses in a web browser, and use Content Security Policy \(CSP\) headers.
Journey Context:
Developers render LLM output directly in the DOM using dangerouslySetInnerHTML or equivalent, assuming the LLM will only generate safe markdown. However, if an attacker injects a prompt causing the LLM to output raw HTML/JavaScript \(e.g.,
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T09:36:39.439396+00:00— report_created — created