Lack or Origin check leads to Cross-Site Websocket Hijacking (CSWSH)
The WebSocket server did not check the Origin header during the handshake, so a malicious page could open a WebSocket connection to the victim's document and read or modify its contents. An attacker who knows a document ID could trick a logged-in victim into visiting a page that performs actions on the document without consent.
- Triaged in 13 hours
- Fixed in 6 days
- Paid in 13 hours
- Disclosed after 9 months
Summary by the program
Summary
@fisher discovered a CSRF-related vulnerability in Coda docs by which an attacked could craft a convincing page that would make modifications to a specific document without the victim knowing. This is due to the inherent nature of Websockets not being secure by default. Although a fully-working proof of concept was not provided, the Coda security team swiftly patched the vulnerability and rewarded a bounty for the creative attack.
Original Report from Researcher
Summary:
It was discovered that when opening a WebSocket channel the Origin header is not checked by the server, leaving the application exposed to a Cross-Site Websocket Hijacking attack (CSWSH).
Background
The problem was first dubbed by Christian Schneider in his blog. Because WebSockets are not restricted by the browser's Same Origin Policy (SOP), if no defensive mechanisms are in place, an attacker can initiate a WebSocket communication from a malicious page targeting the vulnerable wss endpoint - ending up with the ability to communicate two-way with the server.
The most common defensive mechanisms are:
- Checking the Origin header in the first/handshake request (where the Cookie is sent), before issuing a 101 Switching Protocols
- Sending a CSRF token in every WS message
Steps To Reproduce:
We can check this very easily by using a custom extension e.g. Simple Websocket Client
- After installing an extension like the above, login in https://coda.io and open or create a new document while proxying requests through Burp
- Burp has a WebSocket history under Proxy, next to HTTP History. Select any of the URL's used, e.g: https://coda.io/documentsCollab/<docId>/collab/?params=PARAMS&connectionId=CONNECTIONID&EIO=3&transport=websocket
- Open the extension and use this URL(substitute https for wss) and press open:Immediately we connect and receive a message from the server, which confirms the lack of Origin check.
Although the URL might first look like undecipherable to an attacker, the params parameter just holds a base64 value of the document ID: {"documentId":"DOCID"}
Since the document ID is sufficiently long, an attack scenario is:
- User (admin) invites attacker to collaborate on a document (view only)
- Attacker now knows the document ID. He prepares a CSWSH payload and embeds it in a malicious webpage and sends the link to the victim
- Victim opens the malicious page and is Cross Site Websocket Hijacked. The payload could e.g. delete or alter the contents of the document, introducing fake content
Impact
The most serious impact scenario is the attacker forcing the victim to do any operation available within the WebSockets communication (basically a CSRF). He can also read sensitive information (since the WS communication is full duplex).
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the WebSocket handshake did not validate the Origin header and no per-message CSRF token was required, so the server accepted connections from any website.
Impact
An attacker could force the victim to perform any operation available over the WebSocket (a CSRF-like effect) and could also read sensitive information because the channel is full duplex; the report notes a fully working proof of concept was not provided.
What the attacker needed
Victim is logged in; attacker knows the document ID; victim visits a malicious page
The fix
The server should check the Origin header during the handshake and/or require a CSRF token in every WebSocket message; the text says the security team patched the vulnerability.
How it was found
- Log in to the application and open a document while capturing traffic in a proxy.
- Find the WebSocket URL in the proxy's WebSocket history.
- Open a WebSocket client extension, change the scheme to wss, and connect to that URL.
- Observe that the server immediately sends a message, confirming no Origin check.
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 report has not been written yet. The Original tab links to the source.
WebSockets let a browser and a server keep a two-way conversation open. Normally a browser stops one website from reading data from another, but WebSockets are not covered by that rule unless the server checks where the connection comes from. Here the server did not check, so a bad page could talk to the victim's document as if it were the victim.
What is CSRF?
Another site makes a signed-in user's browser perform an action they did not intend.