Skip to content
CSRF Disclosed report Intermediate

The websocket traffic is not secure enough

The WebSocket endpoint did not validate the Origin header, allowing cross-site WebSocket hijacking. An attacker could send messages to the WebSocket from an external origin, potentially performing actions such as login.

arnonymous Follow

Originally disclosed on HackerOne

  • Disclosed after 10 months

'Cross-Site WebSocket Hijacking' is possible, because the websocket connection is not secure (enough). The traffic from and to the websocket can be sniffed with Chrome (see attachment), and replayed elsewhere (cross-domain). Explanation: https://www.christian-schneider.net/CrossSiteWebSocketHijacking.html

Steps: After opening the homepage (https://app.legalrobot-uat.com) a websocket is created after a HTTP request like: https://app.legalrobot-uat.com/sockjs/689/k287_2tz/websocket, with a HTTP101 (switching protocols) response, resulting in a connection wss://app.legalrobot-uat.com/sockjs/689/k287_2tz/websocket.

This (upgrade) request can be called from an external origin.

legarobot-ws-upgrade_2016-10-30_1641_001.png
legarobot-ws-upgrade_2016-10-30_1641_001.png From the original on HackerOne

After knowing the websocket URL, messages (captured in chrome) can be successfully sent.

For example: Open a session: ["{"msg":"connect","version":"1","support":["1","pre2","pre1"]}"] Ping: ["{"msg":"ping"}"] Login: ["{"msg":"method","method":"login","params":[{"user":{"email":"[email protected]"},"password":{"digest":"082a7a2a81c2733fd03567e47e0b6d9f09d32ec80065bda9c5cd34dd1c4f9edf","algorithm":"sha-256"}}],"id":"7"}"] It is also unnecessary, to include the password algorithm in the login message (which can be encrypted with: http://md5decrypt.net/en/Sha256/)

A successful test with above messages using: http://ironwasp.org/cswsh.html (an online test tool).

ironwasp-test_2016-10-30_1909.png
ironwasp-test_2016-10-30_1909.png From the original on HackerOne

Suggestions to fix:

  • Check the origin from the requester server-side and adjust the Origin header for the 'upgrade' request.
  • Add additional 'CSRF tokens'.
  • Encrypt messages, so they cannot be intercepted in Chrome

Additional references: https://www.notsosecure.com/how-cross-site-websocket-hijacking-could-lead-to-full-session-compromise/ https://www.owasp.org/index.php/Testing_WebSockets_(OTG-CLIENT-010) https://humblesoftwaredev.wordpress.com/2016/08/01/securing-websocket-sockjs-connection/

Attachments

websocket_legalrobot_chrome.png
websocket_legalrobot_chrome.png From the original on HackerOne

The original report as published on HackerOne, by arnonymous. Images and videos are our own copies; raw HTML is shown as text. View it on HackerOne.

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

Impact

An attacker could send messages to the WebSocket from an external origin, potentially performing actions such as login, but the report does not demonstrate full session compromise.

What the attacker needed

Attacker knows the WebSocket URL

The fix

The server should check the Origin header on WebSocket upgrade requests and add CSRF tokens.

How it was found

  1. Open the homepage and observe a WebSocket connection being created.
  2. Capture the WebSocket upgrade request and note the WebSocket URL.
  3. Send messages to the WebSocket from an external origin using a tool.

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.

A WebSocket is a two-way connection between a browser and a server. Normally, a website should only accept connections from its own pages. Here, the server accepted connections from any website, so a malicious site could talk to the WebSocket on behalf of a logged-in user.

What is CSRF?

Another site makes a signed-in user's browser perform an action they did not intend.

More by arnonymous

View all

2 more disclosed reports, best first.

More from Legal Robot

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Cross-site request forgery (CSRF)

The lesson behind this report.

Another site makes a signed-in user's browser perform an action they did not intend.