Skip to content

In-depth lesson · Cross-site WebSocket hijacking

Tips for beginners

Every point the Cross-site WebSocket hijacking reports back under this heading, best-backed first, each with the reports it is seen in.

Back to the lesson 1 to 13 of 13
  1. Test whether the server validates the Origin header. Capture the handshake request and resend it with the Origin changed to an external site. If the server still returns a successful upgrade (101 status), it is likely vulnerable.

    Seen in 4 reports
  2. Start by identifying WebSocket endpoints in the application. Look for features like live chat, notifications, collaborative editing, login flows and real-time updates. Use browser developer tools to capture the WebSocket handshake request and note the URL, headers and cookies.

    Seen in 3 reports
  3. Check if authentication relies solely on cookies. If you can connect from a foreign origin using the victim's cookies and receive data or perform actions, that confirms the issue. Use a generic WebSocket client to replay the handshake with the victim's cookies and observe the responses.

    Seen in 3 reports
  4. Look for sensitive data in WebSocket messages. Connect from a cross-site page and see if the server sends chat history, session identifiers, password reset tokens or other private information. This demonstrates impact beyond just establishing a connection.

    Seen in 3 reports
  5. Try to perform state-changing actions over the hijacked socket. Send messages that edit documents, change settings or invite users. If the server accepts them, you have a strong proof of concept.

    Seen in 3 reports
  6. Check for permissive Origin validation. Try origins with special characters or subdomains that might slip past regex checks. Also test if the server parses the Origin in a way that treats a crafted value as an allowed host.

    Seen in 2 reports
  7. When reporting, clearly show the impact. Demonstrate reading private data or performing an action as the victim. Avoid reporting a mere connection without showing what an attacker can do with it.

    Seen in 2 reports
  8. Ensure the endpoint is in scope. Check the program's policy before testing. Do not test on production systems without permission, and avoid actions that could disrupt other users.

    Seen in 2 reports
  9. Test for CSRF token validation issues in related endpoints. Sometimes the WebSocket handshake is protected, but other state-changing requests are not, or the token is checked after the action is performed.

    Seen in 2 reports
  10. Chain WebSocket hijacking with other vulnerabilities. For example, combine it with HTML injection or XSS to bypass CSP or SameSite protections, or use it to leak tokens that enable account takeover.

    Seen in 2 reports
  11. Consider bypasses for common defences. If cookies are SameSite=Strict, look for a reflected XSS on a sibling subdomain to host your page same-site. If a connect-src CSP blocks WebSocket connections, try opening the socket from a WebWorker.

    Seen in 1 report
  12. Test local WebSocket servers in desktop applications. Read the application's source or use network monitoring to find the local port, then create a web page that connects to it and sends commands. These often lack authentication and Origin checks.

    Seen in 1 report
  13. Look for WebSocket endpoints that authenticate with a user identifier instead of a cookie. If you can guess or obtain a victim's identifier, you might connect and receive their messages without needing their session.

    Seen in 1 report