Vulnerable Websocket Server
The WebSocket server accepted connection requests without any CSRF token or origin check, so a malicious page could open a socket as the logged-in victim. The author used this to pull the admin's profile data and change the admin's password, then log in as admin.
Published on infosecwriteups.com
In this article, we will talk about some websocket vulnerabilities. To test for security vulnerabilities, it is necessary to install the repo in the github (https://github.com/Serhatcck/vulnsocket).
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 WebSocket handshake relied only on the victim's session cookie and did not require a user-specific, single-use token or validate the Origin header.
Impact
An attacker could read the admin's profile information and change the admin's password, leading to full account takeover.
What the attacker needed
A free account; victim visits attacker page; attacker hosts a page
The fix
The fixed page sends a user-specific, single-use token with the WebSocket connection request, so an attacker who does not know the admin's token cannot hijack the socket.
How it was found
- Register a user and log in to reach the index page
- Start the WebSocket server with python and refresh the page to connect
- Inspect the WebSocket connection request and messages in Burp Suite
- Host an HTML/JS proof of concept that opens a socket and sends profile data to Collaborator
- Run the exploit script so the admin's browser connects and leaks their data
- Use the leaked admin details to change the password and log in as admin
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. Normally a site proves a request comes from its own pages using a secret token; here the socket connection had no such check, so any other website the victim visited could quietly open a socket in their name and read or change their data.
What is CSRF?
Another site makes a signed-in user's browser perform an action they did not intend.