WebSocket
— WebSocket ProtocolWebSocket provides persistent, low-latency, full-duplex communication channels between client and server over a single TCP connection. Unlike HTTP request/response polling, either side can send messages at any time with minimal frame overhead.
Interactive Session: How WebSocket Works
Step through the packet exchange sequence between nodes.
Interactive Execution Sandbox
Interact with a live or clearly-labelled simulated instance of WebSocket.
Threat Model & Attack Simulation
How this protocol is attacked in practice, what defenders can see, and which control stops it.
Threat model & attack simulation
SimulatedDefensive education. Every step runs in this page; no traffic is generated or sent.
Cross-site WebSocket hijacking
InterceptionA malicious page opens a WebSocket to a victim site and relies on the browser sending session cookies.
Lure the victim
The user visits an attacker page while logged in to the target application.
WebSocket handshakes with a foreign Origin header.
Session takeover and data exfiltration.
Defences that matter
- Validate the Origin header
- Authenticate the socket with a token, not only cookies
- Use SameSite cookies and per-message authorisation
This is a conceptual model for defenders, not an exploit toolkit. It contains no payloads, tooling or instructions for attacking systems you do not own.
Protocol Specification & Architecture
Key characteristics, real-world deployment patterns, and trade-offs.
Core Technical Features
- Initiated via an HTTP 101 Switching Protocols upgrade handshake
- Ultra-thin 2 to 10 byte framing header
- Full-duplex bidirectional data streaming
- Supports text (UTF-8) and binary (ArrayBuffer/Blob) frames
Real-World Use Cases
- Live chat and collaboration tools
- Real-time financial tickers
- Multiplayer online gaming
- Live streaming dashboards
Advantages & Strengths
- Extremely low latency compared to HTTP long-polling
- Persistent socket eliminates per-message connection setup
Limitations & Vulnerabilities
- Requires sticky sessions or pub/sub backplanes to scale across multiple server nodes