XSS Bypass to Zero Click Account Takeover in AI Chatbot
The AI chatbot rendered HTML from user prompts and uploaded files without sanitising dangerous attributes, allowing an attacker to inject an iframe with a srcdoc script. When an admin viewed the conversation, the script executed and stole the admin's session token from local storage.
infosecwriteups.com
Published on infosecwriteups.com
Hi everyone, in this article, I’ll walk through a recent penetration test I conducted against a custom-built AI chatbot. As usual, we’ll cover:
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 application rendered user-supplied HTML without sanitising dangerous attributes such as iframe srcdoc, which allows script execution.
Impact
An attacker could steal an admin's session token, leading to account takeover, but the exploit required the admin to view the conversation or uploaded file.
What the attacker needed
Attacker can send prompts or upload files; admin views the conversation or file
How it was found
- Type HTML tags into the chatbot and observe they are rendered as HTML.
- Try an image tag with an onerror handler and see the handler attribute is stripped.
- Use an iframe with a srcdoc attribute containing a script to trigger an alert.
- Fetch the token from local storage and send it to an external server using no-cors mode.
- Upload a text file containing the iframe payload and ask the chatbot to print the file contents.
- Check the admin logs and confirm the XSS triggered and the admin's session token was captured.
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 displayed whatever HTML a user typed or uploaded, instead of showing it as harmless text. An attacker could put a small script inside an iframe tag, and when an admin later read the chat, that script ran in the admin's browser and sent the admin's login token to the attacker. A token is like a temporary key that proves who you are.
What is XSS?
Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.