| name | wstg-clnt-10 |
| description | Testing WebSockets |
| category | client-side |
| owasp_id | WSTG-CLNT-10 |
| version | 1.0.0 |
| author | cyberstrike-official |
| tags | ["client-side","javascript","dom","cors","wstg","clnt"] |
| tech_stack | [] |
| cwe_ids | ["CWE-200"] |
| chains_with | [] |
| prerequisites | [] |
| severity_boost | {} |
wstg-clnt-10
Test ID
WSTG-CLNT-10
Test Name
Testing WebSockets
High-Level Description
WebSockets provide full-duplex communication channels over a single TCP connection. Security issues can arise from missing authentication, lack of input validation, cross-site WebSocket hijacking, and insecure data transmission.
What to Check
How to Test
Step 1: Identify WebSocket Endpoints
console.log("WebSocket instances:", window.WebSocket)
const originalWS = window.WebSocket
window.WebSocket = function (...args) {
console.log("WebSocket created:", args)
return new originalWS(...args)
}
Step 2: Test WebSocket Security
import asyncio
import websockets
import json
class WebSocketTester:
():
.ws_url = ws_url
.findings = []
():
()
origins = [
,
,
,
]
origin origins:
:
headers = {: origin}
websockets.connect(
.ws_url,
extra_headers=headers
) ws:
()
.findings.append({
: ,
:
})
Exception e:
()
():
()
:
websockets.connect(.ws_url) ws:
ws.send(json.dumps({: }))
response = asyncio.wait_for(ws.recv(), timeout=)
()
()
.findings.append({
: ,
:
})
Exception e:
()
():
()
payloads = [
,
,
,
]
:
websockets.connect(.ws_url) ws:
payload payloads:
ws.send(payload)
:
response = asyncio.wait_for(ws.recv(), timeout=)
()
()
:
Exception e:
():
.test_origin()
.test_no_auth()
.test_injection()
tester = WebSocketTester()
asyncio.run(tester.run_tests())