CHATBREAKER
Pricing Guides Blog Threat Pulse Log inSign up
  1. Home
  2. Blog
  3. Can Chatbot Output Create an XSS Risk?

Blog · ← All posts

Can Chatbot Output Create an XSS Risk?

Published: November 14, 2026 · Reviewed: November 14, 2026 · 6 min read

By the Ingenious AI team

Share: X Facebook LinkedIn WhatsApp

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.

What is chatbot output handling? Chatbot output handling is the discipline of treating everything a model emits — text, markdown, links, code, HTML fragments — as untrusted content before it is rendered, stored, emailed or executed anywhere, because a manipulated bot can be made to emit active content such as script-bearing markup or malicious links.

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

  1. 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.
  2. Validate every bot-emitted link against scheme and domain policy; contacts and destinations come from verified tools, not model text.
  3. Never auto-execute, auto-install or one-click-run code the bot produces; treat generated files and filenames as hostile input.
  4. Probe the sinks: make the bot emit representative markup with di-04/di-01, then follow the payload through every rendering path.
  5. 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.

Related guides

  • Red-Team Chatbot Checklist 2026
  • Can a Chatbot Leak Its System Prompt?
  • AI Red Teaming for Chatbots: What Gets Tested
  • Prompt Injection in Customer Chatbots: 5 Attack Shapes
  • How Often Should You Red-Team a Chatbot?
  • Guide: The Ten Attack Classes
  • Guide: Mutation-Test Your Fix
  • Guide: Business-Logic Attacks
  • Run the free red-team test
  • Threat Pulse: attacks circulating now
  • ChatBreaker pricing
  • What Are False Memory (Echo Chamber) Attacks on a Chatbot?
ChatBreaker · by Ingenious AI · automated red-teaming — test only chatbots you own or are authorized to test · About · Blog · Guides · Contact · Privacy · Terms · Security · Free Chatbot Security Test · Business-Logic Attacks · Catch Silent Model Swaps · Mutation-Test Your Fix · Ten Attack Classes
More from Ingenious AI:
DisclosureGuard — AI disclosure compliance · Vibe-Code Audit — AI code security scanner · Rogue-Agent Defense — AI agent firewall · BreachHunter — website penetration testing · ModelMinder — AI model deprecation radar · TermsWatch — AI vendor terms monitor · Agent Flight Recorder — tamper-evident agent audit trails · Agent Auth Gateway — agent credentials & kill switch · DomainGuard — domain impersonation defense · Agent Passport — Know-Your-Agent registry · AgentGate — agent policy publisher · AgentBlock — AI agent & crawler access control · BoundaryVault — agent log forensics · Agentic Receipts — verifiable agent payment receipts · EvalEgress — eval-to-production exposure scan · HomeShield MCP — home AI server exposure check · WireWatch — payment verification ceremony · ADMT Notice Kit — AI decision notice compliance · DueLadder — human-approved invoice chasing · Agent-Ready Store Audit — can AI agents buy from your store · ContentCraft AI — content operations · AgentReady — agent-readiness checks · AI Audit Exchange — AI audit exchange · CallbackShield — callback & webhook protection · CompanionGuard — AI companion safety guardrails · CRAClock — EU Cyber Resilience Act deadline clock · EInvoice Translator — e-invoice format translator · GEOFixer — geo & local listing fixes · MandateGuard — agent spending mandates · OutcomeMeter — AI outcome measurement · ProvenanceGuard — content provenance checks · ReviewDesk — review response desk · ReviewProof — verified review evidence · TakedownCoop — coordinated phishing takedowns · TrustGate — trust & safety gating · ChatBreaker — AI chatbot red-teaming · All 36 platforms — the Ingenious AI portfolio

We use cookies. Necessary cookies keep the site working. With your permission we also use analytics cookies (to understand usage) and marketing cookies (for ads). Read our privacy policy.

NecessaryRequired for login, security and core features. Always on.
AnalyticsHelps us understand which pages are useful.
MarketingUsed for advertising and measuring ad performance.
↑↓ navigate · Enter open · Esc close
← Go back