WebSockets
A live chat feature built on WebSockets rendered chat messages without adequate sanitisation, so a crafted message could run script in the support agent's browser. A second lab shows the chat endpoint lacked CSRF protection, letting an attacker page open a WebSocket as the victim and read their chat history, which contained a password.
medium.com
Published on medium.com
To solve the lab, use a WebSocket message to trigger an alert() popup in the support agent's browser.
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 chat messages were inserted into the page without proper output encoding, and the WebSocket handshake relied only on cookies with no anti-CSRF token.
Impact
An attacker could run script in a support agent's browser, and in the hijacking case could steal a victim's chat history including their password and take over the account.
What the attacker needed
Live chat feature; victim visits attacker page (hijack lab); victim logged in with active session
How it was found
- Open the live chat and send a few messages to confirm traffic goes over WebSockets.
- Send a basic script-tag payload, which fails, then try an image-tag payload, which fires.
- For the hijacking lab, reload the page and note the chat history loads automatically, tied to the session cookie.
- Observe the first message sent is a ready signal and the server replies with the chat history.
- Visit the chat endpoint and confirm no CSRF token is present.
- Host a script on the exploit server and deliver it to the victim, then read the exfiltrated history and log in 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 WebSocket is a two-way connection a web page keeps open with a server, here used for live chat. The site put whatever users typed straight into the agent's chat window without cleaning it, so text could act as code and run in the agent's browser. In the second case, the chat connection trusted the browser's saved login cookie alone, so another website could open that connection on the victim's behalf and read their messages.
What is XSS?
Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.