Usage of insecure websocket connection

Description

Your application is at risk when it connects to APIs via insecure websocket connections. This vulnerability occurs because the data transmitted over these connections can be intercepted or tampered with by attackers. Ensure that all websocket connections in your application use SSL to encrypt the data in transit, safeguarding it from unauthorized access.

Remediations

  • Do not initiate websocket connections without SSL. Such connections are vulnerable to interception and compromise.
    const client = new WebSocket('ws://insecure-api.com'); // unsafe
  • Do ensure all websocket connections are secured with SSL. This encrypts the data transmitted, protecting it from eavesdroppers and tampering.
    const client = new WebSocket('wss://secure-api.com');

References

Associated CWE

OWASP Top 10

Configuration

To skip this rule during a scan, use the following flag

bearer scan /path/to/your-project/ --skip-rule=javascript_lang_websocket_insecure

To run only this rule during a scan, use the following flag

bearer scan /path/to/your-project/ --only-rule=javascript_lang_websocket_insecure