Skip to content
XSS Write-up Beginner

XSS via HTML Injection in Chatbot

A chatbot on a website rendered user-supplied HTML without sanitisation, allowing HTML injection. The reporter then used a button element with an onclick handler to execute JavaScript and read the document cookie.

nidishms1999 Follow

Published on medium.com

The original lives on medium.com

We do not hold its text, 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 output was inserted into the page as raw HTML without sanitising or escaping user input.

Impact

An attacker could execute arbitrary JavaScript in the context of the chatbot page, potentially stealing cookies or performing actions as the victim.

What the attacker needed

Access to the chatbot interface

How it was found

  1. Open the website with the chatbot.
  2. Enter a simple HTML heading tag into the chatbot.
  3. Observe that the HTML is rendered rather than shown as text.
  4. Enter a button element with an onclick handler that calls alert with document.cookie.
  5. Observe the alert firing, confirming script execution.

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.

A chatbot on a website displayed whatever HTML a user typed into it instead of showing it as plain text. Because of that, an attacker could make the chatbot run JavaScript code in the browser of anyone who viewed the chat, which could let them read cookies or act as the victim.

What is XSS?

Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.

Similar reports

View all

Same bug class and techniques, clearest first.

Cross-site scripting (XSS)

The lesson behind this report.

Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.