Skip to content

[BACKEND] WebSocket endpoints accept unauthenticated connections; /ws/user/{id} leaks private events #375

@Hydrax117

Description

@Hydrax117

Description:
All four WebSocket handlers set user_id: None with a TODO comment:

WebSocketConnection {
    id: Uuid::new_v4(),
    user_id: None, // TODO: Extract from JWT token

The /ws/user/{id} endpoint is especially dangerous — any anonymous caller can subscribe to any user's private event stream by guessing or enumerating a UUID. Match result notifications, Elo changes, and matchmaking status are all exposed.

Affected files: src/realtime/websocket.rs

Proposed fix: Extract the JWT from the Authorization header or a token query parameter during the WebSocket upgrade handshake. Reject the upgrade with 401 if the token is missing or invalid. For /ws/user/{id}, verify that the authenticated user's ID matches the path parameter.


Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions