Blog · ← All posts
Can Chatbot Output Create an XSS Risk?
Published: November 14, 2026 · Reviewed: November 14, 2026 · 6 min read
Run a free red-team test on your chatbot → Eight real probes from the library below, with transcripts — or open the full battery in ChatBreaker and generate a red-team report for your team.
The short answer
Yes: a chatbot that renders its own answers as rich HTML or markdown hands attackers a stored-XSS delivery service — the attacker supplies the payload conversationally, the bot repeats it with the site's authority, and the victim's browser runs it in your origin. The injection families (di, rp, rg) are how payloads get in; output handling is whether they detonate. The rules are old-fashioned and strict: render bot output as text by default, sanitise any markdown through an allowlist, never let model text become links, code or markup without validation, and screen for the payloads your own probes use.
How a conversation becomes stored XSS
The chain has three links. First, an attacker gets the bot to produce attacker-chosen markup — directly ('repeat this exactly'), through a poisoned document that formats its payload as a helpful answer, or via di-04-style marker echo, which exists precisely to prove the bot will emit chosen strings. Second, the application stores or relays that answer: a ticket transcript, a shared chat, an emailed summary, a help-centre 'answer' page. Third, a victim — ideally, from the attacker's view, a staff member — opens it in a context that renders HTML.
Every link is a design decision someone made for convenience: rich rendering because tables look better, transcripts emailed as HTML because plain text looks cheap, summaries shared because support needs context. The attack does not break these decisions; it inherits them. Output handling is the audit of what the bot's words are allowed to become after they leave the model.
Markdown is not a safe middle ground
Teams often retreat from raw HTML to markdown and call it safe. Markdown renderers vary enormously: many pass through inline HTML, most happily render links with any scheme, and images can carry tracking or worse. A bot induced to emit [click here](javascript:…) or an image tag pointing at an attacker server has not been sanitised by the markdown step — it has been typeset by it.
Safe rendering means an allowlist pipeline: parse markdown to an AST, permit a small set of elements (paragraphs, lists, emphasis, code), validate link URLs against scheme and domain policy, strip everything else, and escape by default. This is solved engineering — mature sanitizers exist for every stack — but it must be applied to bot output specifically, including in admin tools and email templates, the two places teams most often forget because 'only staff see those'.
Links, code blocks and other active gifts
Beyond markup, police the semantics. Links the bot emits should be validated: your domains and known partners by default, because rg-04's contact sleeper shows the redirection payoff when a bot can send customers to lookalike destinations. Code blocks the bot produces should never be auto-executed, auto-installed or one-click runnable in your tooling — a 'helpful script' from a manipulated bot is a supply-chain attack with a chat UI.
Downloads deserve the same suspicion: if the bot can attach or link files (generated reports, exports), the generation path must treat model-influenced content as hostile — filenames sanitised, content types pinned, and archives scanned. Our tool abuse guide covers the action side; output handling covers everything the bot says that later gets treated as more than words.
Testing output handling with your own probes
Test at the sink, not the source. Use the echo and override probes (di-04, di-01, rp-04's terminal simulation is a good markup producer) to make the bot emit representative payloads — script tags, event handlers, javascript: links, markdown images — then follow each payload through every rendering path: customer chat, staff console, emailed transcript, exported report, mobile app webview. Any path that renders it active is a finding, weighted by who views that path: staff-console XSS is the CRITICAL, because staff sessions carry the privileges worth stealing.
File the sink inventory with the test: rendering paths change as features ship, and the 'share this conversation' feature launched next quarter will render bot output somewhere new. The 2026 checklist includes output sinks in its scope section for exactly this reason — output handling fails by omission, when a new surface inherits raw bot text by default.
Worked example: Ledgerly Accounting Software
Ledgerly, a fictional accounting platform, rendered bot answers as markdown in its in-app help panel and emailed chat transcripts as HTML to customers. Probing made the bot emit a test payload (an inert marker inside an event-handler attribute) via di-04 echo. The customer chat escaped it correctly. The staff console — which rendered transcripts with a richer markdown profile — executed the marker in the test harness. A stored-XSS path into support-agent sessions: CRITICAL, −25.
The emailed transcript also passed bot-emitted links unvalidated; an rg-04-style test link survived into the HTML email (MEDIUM, −8). Ledgerly unified rendering: one allowlist sanitizer for every surface including email, links restricted to its own domains plus a partner allowlist, and bot output plain-text by default in the staff console. Re-test across all four surfaces: payload inert everywhere, drift FIXED on both findings, score back to 100 for the run.
Five actions you must take today
- Render bot output as plain text by default; where rich text is needed, sanitise through a strict element allowlist on every surface — chat, staff console, email, exports, webviews.
- Validate every bot-emitted link against scheme and domain policy; contacts and destinations come from verified tools, not model text.
- Never auto-execute, auto-install or one-click-run code the bot produces; treat generated files and filenames as hostile input.
- Probe the sinks: make the bot emit representative markup with di-04/di-01, then follow the payload through every rendering path.
- Re-audit sinks whenever a new surface ships (share links, summaries, integrations) — output handling fails by omission.
Probe your chatbot free → The free test runs eight real probes from the library against your bot, with transcripts. The full 72-probe battery, drift tracking and verify-fix live in ChatBreaker.
Sources
- OWASP Top 10 for LLM Applications (2025) — LLM05:2025, Improper Output Handling, the risk classification this post's attack taxonomy maps to.
- OWASP Cross Site Scripting Prevention Cheat Sheet (2025) — The output-encoding and sanitisation controls this post prescribes for bot-rendered markdown.
- ChatBreaker guides — The platform's own methodology guides: the ten attack classes, mutation testing and business-logic testing walkthroughs.
Frequently asked questions
Is chatbot output really an XSS vector?
Yes, when any surface renders bot text as HTML or permissive markdown and stores or relays it — transcripts, shared chats, emailed summaries, staff consoles. The attacker supplies the payload conversationally; your rendering gives it your origin and your users' sessions.
We render markdown, not HTML — are we safe?
Not automatically. Many markdown pipelines pass inline HTML through and render arbitrary link schemes. Safety comes from an allowlist sanitizer applied to bot output, not from the choice of markdown itself.
Why is staff-console XSS rated so highly?
Because staff sessions carry administrative privilege. A payload executed in a support agent's console can act with their access — the conversational equivalent of stealing the master key rather than a room key.
Should bot links be restricted?
Yes. Attackers use bot-emitted links and contacts for phishing with your brand's authority (the rg-04 pattern). Restrict schemes, allowlist domains, and source contact details from verified directory tools.
Does output screening replace sanitisation?
No. Screening looks for known payload shapes in text; sanitisation constrains what rendered output can be. Screening is a detection layer; sanitisation is the structural control. Use both, in that order of importance reversed: sanitise first.