WebSocket Penetration Testing: Auth, Hijacking & Logic Flaws
Manual WebSocket penetration testing guide: Cross-Site WebSocket Hijacking (CSWSH), missing per-message authorization, and rate-limit bypasses.
Web & App Security · By Thimmagurudu Bathini, CTO · Published · 5 min read
Why HTTP-Only Pentests Miss Real-Time Flaws
Real-time trading dashboards, chat apps, collaboration tools, and live notifications rely on WebSockets—yet security teams often test only HTTP REST routes. Because WebSockets maintain long-lived stateful connections, missing Origin validation or per-message authorization checks create high-impact flaws.
# Attempt WebSocket upgrade with untrusted Origin header
curl -i -N -H "Connection: Upgrade" -H "Upgrade: websocket" \
-H "Origin: https://evil.example" \
-H "Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==" \
-H "Sec-WebSocket-Version: 13" https://ws.example.com/stream
# Secure server rejects with HTTP 403 ForbiddenWebSocket Handshake, Auth & Frame Risks
| WebSocket Layer | Common Vulnerability | How Testers Verify |
|---|---|---|
| Handshake (HTTP Upgrade) | Missing Origin check allows Cross-Site WebSocket Hijacking | Initiate wss:// upgrade from an untrusted cross-origin page |
| Authentication | Session revocation does not close active WebSocket | Revoke user token and confirm whether socket still receives events |
| Message Authorization | User subscribes to another tenant's channel/room ID | Replay subscribe/join frames with another customer's room UUID |
| Input Handling | XSS, SQLi, or JSON injection inside socket payloads | Fuzz message fields and trace downstream DB/UI sinks |
Testing Channel Subscriptions Across Tenants
- Intercept ws:// and wss:// upgrade handshakes and check Origin validation plus CSRF/token binding.
- Test channel subscription and room-join messages for horizontal BOLA across tenants.
- Verify whether rate limiting and payload size caps apply to individual WebSocket frames.
- Confirm logging out or revoking permissions immediately terminates active sockets.
Securing Upgrade Handshakes & Frame Auth
Validate the Origin header during the HTTP upgrade handshake, authenticate via short-lived per-connection tokens, and authorize every inbound message frame.
Include real-time WebSocket streams in your web and API VAPT scope from ₹36,000 + 18% GST. Request a scoped proposal →
WebSocket Penetration Testing Questions
Do automated DAST scanners test WebSockets?
Most standard DAST scanners skip or only lightly probe WebSocket frames; manual interception is required for channel-level authorization.
Does API VAPT cover WebSockets?
Yes, WebSocket endpoints in your application scope are tested as part of our manual web and API VAPT from ₹36,000 + 18% GST.