Skip to content
XSS Write-up Intermediate

From “Meh, It’s Just Reflected XSS” to “Sh*t, I Own the C

A reflected XSS vulnerability in an AI chatbot allowed execution of arbitrary JavaScript, and because authentication tokens were stored in localStorage, an attacker could steal a high-privilege user's session token and achieve account takeover.

Shah kaif Follow

Published on infosecwriteups.com

By Shah kaif | How I went from disappointment to shock in 30 minutes |LinkedIn | Youtube

Shah kaif, on infosecwriteups.com

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 reflected user-supplied HTML/JavaScript without sanitisation, and the application stored authentication tokens in localStorage, making them accessible to any JavaScript running on the page.

Impact

An attacker could steal a high-privilege user's session token and gain full account takeover, accessing internal systems and data.

What the attacker needed

Victim views the malicious chatbot message; victim has an active session

The fix

The application should store authentication tokens in HTTP-only cookies and sanitise chatbot output to prevent XSS.

How it was found

  1. Test the AI chatbot with XSS payloads and observe they execute.
  2. Inspect browser DevTools to find authentication tokens stored in localStorage.
  3. Craft a payload that reads the token from localStorage and sends it to an external server.
  4. Send the payload via the chatbot and wait for the token to be exfiltrated.
  5. Decode the stolen JWT to identify the victim account.

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.

The chatbot echoed back user input without cleaning it, so a malicious script could run in a victim's browser. The site also kept login tokens in a place any script can read, so the script could copy the token and let the attacker log in as that user.

What is XSS?

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

More by Shah kaif

View all

5 more disclosed reports, best first.

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.