# WebSocket Security Issues

> Detects insecure WebSocket implementations including missing origin validation, lack of authentication, and message injection risks.

- Skill: `zakirkun/websocket-security-issues` (Agent Skill, multi-file: 2 files)
- Install (CLI): `npx skillmds@latest add zakirkun/websocket-security-issues`
- Raw SKILL.md: https://api.skillmd.com/api/skills/zakirkun/websocket-security-issues/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Security
- Author: zakirkun (https://skillmd.com/u/zakirkun)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/zakirkun/websocket-security-issues

---


# WebSocket Security Issues

## Overview
WebSocket connections bypass same-origin policy — browsers send cookies with WebSocket upgrade requests, making them vulnerable to:
1. **Cross-Site WebSocket Hijacking (CSWSH)**: No `Origin` header validation allows cross-origin connections
2. **Missing authentication**: WebSocket handlers that don't verify the user is logged in
3. **Message injection**: User-controlled messages echoed back without sanitization

## Detection Strategy
- WebSocket `upgrade` handlers that don't verify the `Origin` header
- WebSocket handlers that don't check session/token before processing messages
- Message data broadcast directly without sanitization

## Remediation
- Validate `Origin` header against an allowlist
- Require valid session/JWT before accepting WebSocket connection
- Sanitize all messages before broadcasting

