CWE-1385

Missing Origin Validation in WebSockets

Medium

Description

The product uses a WebSocket, but it does not properly verify that the source of data or communication is valid.

Potential Impact

How to Fix

Implementation

Enable CORS-like access restrictions by verifying the 'Origin' header during the WebSocket handshake.

Implementation

Use a randomized CSRF token to verify requests.

Implementation

Use TLS to securely communicate using 'wss' (WebSocket Secure) instead of 'ws'.

Architecture and Design

Require user authentication prior to the WebSocket connection being established. For example, the WS library in Node has a 'verifyClient' function.

Implementation

Leverage rate limiting to prevent against DoS. Use of the leaky bucket algorithm can help with this.

Related Weaknesses

References

View on MITRE CWE Database →

Need Help Fixing This Vulnerability?

Our security experts can help you identify and remediate CWE-1385 vulnerabilities in your codebase.

Get Security Assessment