XSS in WebSocket Messages: Common Mistakes and Fixes
WebSockets make it ridiculously easy to stream untrusted data straight into the DOM. That’s why XSS bugs in real-time apps are so common: chat, notifications, dashboards, admin consoles, trading UIs, collaborative editors — they all take server messages and render them fast, often without the same discipline teams apply to normal HTTP responses. I’ve seen teams lock down templates, escape server-side HTML, add CSP, and still ship XSS because one socket.onmessage handler quietly did innerHTML = data.message. ...