Skip to main content
LowAPIOWASP A05:2021CWE-346

How to fix: WebSocket endpoint reachable, Origin handling unconfirmed

A WebSocket-shaped endpoint was reachable and its response body doesn't reference Origin handling. This is a static content heuristic, not a live handshake test with a foreign Origin header, so it flags something to verify manually rather than a confirmed missing check.

Why it matters

If the WebSocket handshake genuinely ignores the Origin header, any malicious website a victim visits can silently open an authenticated WebSocket connection using the victim's session cookies, then subscribe to their real-time events: a CSRF equivalent that is invisible to the user.

Origin validation happens server-side during the HTTP upgrade request and isn't observable in the page's static body content in either direction: a hardened server with a bare bootstrap page and an unhardened server whose unrelated JS happens to mention 'origin' would both be scored incorrectly by content alone.

How to fix it

  1. 1Validate the Origin header against an allowlist during the HTTP upgrade handshake
  2. 2Reject the connection with HTTP 403 if Origin is not in the allowlist
  3. 3Additionally require a CSRF token in the initial WS message for critical endpoints

Code examples

ws library: Origin validation on upgrade

JavaScript
import { WebSocketServer } from 'ws';

const ALLOWED_ORIGINS = new Set(['https://app.example.com']);

const wss = new WebSocketServer({
  server: httpServer,
  verifyClient({ origin }, callback) {
    if (!origin || !ALLOWED_ORIGINS.has(origin)) {
      callback(false, 403, 'Forbidden: origin not allowed');
    } else {
      callback(true);
    }
  },
});

Socket.IO: built-in CORS origin check

JavaScript
import { Server } from 'socket.io';

const io = new Server(httpServer, {
  cors: {
    origin: ['https://app.example.com'],
    methods: ['GET', 'POST'],
    credentials: true,
  },
});

References

Detected automatically by VulnRadar. The check id is api-websocket-no-origin-validation, stable across every scan so you can filter or diff on it.

See every api check

Questions

How severe is WebSocket endpoint reachable, Origin handling unconfirmed?
VulnRadar rates this low severity in the api category. The severity is fixed per check, not scored per site, so the same finding is the same severity on every scan.
Does VulnRadar check for this automatically?
Yes. It runs as part of every scan under the check id api-websocket-no-origin-validation, which stays the same between runs so you can filter, diff, or gate CI on it.
Which standards does WebSocket endpoint reachable, Origin handling unconfirmed map to?
It maps to CWE-346. In the OWASP Top 10 it falls under A05:2021.

Missing a check?

The detection set is open. If you know a misconfiguration this does not catch, propose it: the issue template asks for the threat model, how to detect it, the false-positive risk, and a test fixture, which is the same thing a maintainer would have to work out anyway.

Propose a checkHow a check is built

Scan your own site for websocket endpoint reachable, origin handling unconfirmed

VulnRadar runs this check and hundreds more against a URL in seconds. No agent to install, just paste a URL.

Or scan this site as a demoRead the docs

WebSocket endpoint reachable, Origin handling unconfirmed | VulnRadar