Advanced XSS Payload Write-Up: DOM Injection via Chatbot / HTML
A chatbot that rendered user messages as raw HTML allowed injected markup to run JavaScript in the chat window and in notification emails. An attacker could steal cookies, redirect users to phishing sites, or exfiltrate data via postMessage.
Published on medium.com
While testing a chatbot that renders messages or UI content as raw HTML, I identified multiple ways to execute JavaScript using enhanced XSS payloads.
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the chatbot and email templates inserted user-supplied messages into HTML without sanitising or context-aware encoding.
Impact
An attacker could steal cookies or sessions, redirect users to phishing sites, and exfiltrate data via postMessage; the text claims the payloads bypassed basic WAF filters and HTML escapes, and that email delivery turns this into stored XSS affecting other users.
What the attacker needed
Ability to send a message to the chatbot; victim views the chat or email
The fix
User input should be sanitised with a library such as DOMPurify, rendered with textContent instead of innerHTML, encoded for its output context, and restricted by a Content-Security-Policy.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
When a website puts what you type into a page without cleaning it first, any code you type can run in other people's browsers. This is called cross-site scripting, or XSS. Here the chat box and the emails it sent did not clean the messages, so a crafted message could run code.
What is XSS?
Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.