You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jan 29, 2026. It is now read-only.
Currently, the WebSocket server at backend/src/websocket/server.js accepts connections without any authentication. This allows any client to connect to /ws and receive real-time workflow and store state updates, potentially exposing sensitive data.
Current Implementation
// backend/src/websocket/server.js (lines 51-55)handleConnection(ws,req){constclientId=`client-${Date.now()}-${Math.random().toString(36).substr(2,9)}`;// No authentication check!this.clients.set(clientId,ws);ws.isAlive=true;// ...}
Security Risk
Unauthenticated access to real-time workflow data
Potential data leakage to unauthorized clients
No access control for WebSocket connections
Bypasses the API key authentication used in HTTP routes
Recommended Solution
Implement API key authentication for WebSocket connections by:
Extract API key from query parameters or upgrade request headers
Validate against existing auth middleware logic
Close connection with proper status code if authentication fails
Store authenticated client metadata
// Suggested implementation for backend/src/websocket/server.jshandleConnection(ws,req){// Extract API key from query paramsconsturl=newURL(req.url,'ws://localhost');constapiKey=url.searchParams.get('apiKey');// Validate API key (reuse logic from backend/src/api/middleware/auth.js)constDEFAULT_API_KEY=process.env.API_KEY||'dev-api-key-change-in-production';if(!apiKey||apiKey!==DEFAULT_API_KEY){console.warn(`❌ Unauthorized WebSocket connection attempt from ${req.socket.remoteAddress}`);ws.close(1008,'Unauthorized');// Policy Violationreturn;}// Continue with authenticated connectionconstclientId=`client-${Date.now()}-${Math.random().toString(36).substr(2,9)}`;this.clients.set(clientId,{ ws,authenticated: true,connectedAt: Date.now()});// ...}
🔒 Priority: HIGH - Security & Stability
Background
Currently, the WebSocket server at
backend/src/websocket/server.jsaccepts connections without any authentication. This allows any client to connect to/wsand receive real-time workflow and store state updates, potentially exposing sensitive data.Current Implementation
Security Risk
Recommended Solution
Implement API key authentication for WebSocket connections by:
Files to Modify
backend/src/websocket/server.js(handleConnection method, lines 51-72)backend/src/api/middleware/auth.jsAcceptance Criteria
Testing Plan
References
backend/src/api/middleware/auth.jsbackend/src/websocket/server.jsAdditional Context
This issue blocks production deployment and should be addressed before exposing the WebSocket endpoint to untrusted networks.