Silent Sabotage: Exploiting Stored XSS in a Chat Feature
The chat feature stored user messages without sanitising them, so a script embedded in a message ran in the recipient's browser when they opened the chat. An attacker could steal the victim's session cookie and take over their account.
youssefhussein212103168 Follow
Published on medium.com
During a recent penetration testing engagement, I discovered a Stored Cross-Site Scripting (XSS) vulnerability within the chat feature of an e-commerce platform. This platform consisted of sellers and buyers negotiating prices through a built-in chat system.
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 chat message was stored and later rendered without output encoding or sanitisation, so HTML and script tags were treated as code.
Impact
An attacker could hijack the session of anyone they chatted with, leading to impersonation, phishing or account changes; the text does not mention any defence that blocked it.
What the attacker needed
An account on the platform; victim opens the chat with the attacker
The fix
The application should encode or sanitise chat messages on output, add a Content Security Policy and set session cookies as HttpOnly.
How it was found
- Send a chat message containing a script tag to the victim.
- The victim opens the chat and the script runs in their browser.
- The script sends the victim's session cookie to the attacker's server.
- The attacker uses the stolen cookie to act as the victim.
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 chat message is saved and shown to the other person. The site did not clean the message before showing it, so if someone typed code instead of text, the browser ran that code. That let the sender read the other person's login cookie and act as them.
What is XSS?
Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.