Skip to content

Use secure WebSocket (wss) instead of insecure ws connections #134

Description

@sourcery-ai

Summary

A potential security issue has been identified in the JavaScript codebase related to the use of insecure WebSocket connections. The automated analysis (Sourcery / opengrep) flagged javascript.lang.security.detect-insecure-websocket, indicating that a ws:// WebSocket is being used where wss:// (WebSocket Secure) should be used.

Details

  • Tool: Sourcery / opengrep
  • Rule: javascript.lang.security.detect-insecure-websocket
  • Issue: Insecure WebSocket Detected
  • Current behavior: At least one WebSocket connection in the code uses the non-secure ws:// protocol.
  • Expected behavior: All WebSocket connections should use wss:// to ensure transport-level encryption and mitigate eavesdropping/man-in-the-middle attacks.

This may affect any feature that relies on real-time communication over WebSockets, especially in production environments or when handling sensitive data.

Impact

Using ws://:

  • Leaves WebSocket traffic unencrypted on the network.
  • Can expose sensitive data to network observers.
  • May violate security best practices and organizational policies.

Suggested Fix

  1. Locate all WebSocket initializations using ws:// (e.g., new WebSocket('ws://...')).
  2. Change them to use wss:// (e.g., new WebSocket('wss://...')), ensuring the backend/server supports secure WebSockets (TLS/SSL) on the corresponding endpoint.
  3. If running behind a reverse proxy (e.g., Nginx, HAProxy, Cloudflare), ensure WebSocket upgrades and TLS termination are correctly configured.
  4. Confirm that any local/dev environments are updated to support wss:// or provide a clearly separated dev-only configuration.

Action Items

  • Identify the file(s) and line(s) where ws:// WebSockets are used.
  • Confirm the WebSocket server(s) support wss:// and have valid TLS certificates.
  • Update WebSocket URLs from ws:// to wss://.
  • Add tests or checks (lint/static analysis) to prevent introduction of new insecure WebSockets.
  • Document the requirement to use wss:// in the project’s security or contribution guidelines.

References


I created this issue for @Its4Nik from #132 (comment).

Tips and commands

Getting Help

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions