Skip to content

Chapter 1

Finding the socket

The second server does not announce itself in the route list.

3 min readWebSocket

You cannot test a socket you never noticed. Because standard crawlers and scanners skip WebSockets by default, you have to look for them on purpose while mapping the app.

Apps rarely advertise their sockets in the UI. Look instead for features that update live without a page reload. Chat widgets, notification bells, online dots, collaborative editors, and live tickers are common clues. Whenever a screen refreshes on its own, assume a socket is running behind the scenes until your proxy proves otherwise.

Start by pulling the app’s JavaScript bundles into a local js-bundle folder, sticking strictly to in-scope hosts.

Terminal window
mkdir -p js-bundle
curl -s https://target.com/ | grep -Eo 'src="[^"]+\.js"' | cut -d'"' -f2 > js-urls.txt

Edit each line of js-urls.txt into a full URL. Then download the files.

Terminal window
wget -q -P js-bundle -i js-urls.txt

Many apps load more script chunks on demand. Click through the app with the browser Network tab open, filter on JS, and save the new files too.

Run both searches on the script bundle.

Terminal window
grep -rEo "wss?://[a-zA-Z0-9./_:-]+" js-bundle/*.js | sort -u
grep -rE "new WebSocket|Socket\.io|reconnect|\.onmessage" js-bundle/*.js
  1. Run the two commands above.
  2. If they are quiet, search for SockJS, SignalR, ActionCable, Phoenix.Socket, and graphql-ws.

The first command misses some URLs. A host with a percent-encoding, or a string built in pieces, will not match that class. Search for the constructor name when the URL search is empty.

Burp Proxy can record sockets. You see them only when the browser sends them through the proxy. Check that your proxy route includes the socket host. Find the handshake in HTTP history. It is a GET request that received status 101.

  1. Open that GET request in HTTP history.
  2. Choose Create WebSocket session.
  3. Replay, intercept, and edit frames in that session.

What you already know about Repeater applies to those frames. The frames are not in the main HTTP history. Most hunters never open the WebSocket history tab. Open it on every target.

The browser tools do the same job in a smaller view. In the network log, filter on WS. You want the handshake and the frame list, not only the pretty UI.

wss://target.com/ws
wss://target.com/socket.io/?EIO=4
wss://ws.target.com
wss://target.com/chat
wss://target.com/notifications
wss://target.com/admin
wss://target.com/live
ws://target.com

/ws is the obvious path. /socket.io/?EIO=4 is Socket.IO. Socket.IO puts its own packets inside the frames. A connect packet looks like 40 plus a JSON object, for example 40{"token":"..."}. Test the HTTP handshake and that first packet as two checks. A token in one of them does not mean the other one was checked.

wss://ws.target.com is a different host. It sometimes uses a different login from the site you just tested. Treat it as its own app until the session is proven to be shared.

/chat, /notifications, /admin, and /live are common paths. /admin is not decoration. Live admin dashboards are a normal place for a socket. The role check for that path sometimes runs only on the handshake. Sometimes the role check never runs. Request the admin path with the lowest role you have.

ws:// has no TLS. The families chapter says when that is a real bug, and when the browser blocks it. The checklist asks the question again. Record every hit, then prove whether a client actually connects.

Also search these path fragments when the bundle is minified.

/websocket
/sockjs
/hub
/signalr
/cable
/graphql
/subscriptions

A mobile app uses the same handshake. Proxy the device and look for status 101. Server-sent events are a different mechanism. EventSource stays on HTTP, and the client does not send frames back. Status 101 plus Upgrade: websocket means this guide. A long GET with text/event-stream does not. A live page can use either one. Check the status line before you write the bug up.

Next, Chapter 2 tests the handshake from another origin.

Connections2 backlinks · 4 outgoing · 6 cross-guideFull graph →
Open local graph around this page
Open full graph →
Click a node to open · Drag to reposition · Scroll to zoom

WebSocketFor authorized testing only.