ccsync icon indicating copy to clipboard operation
ccsync copied to clipboard

WebSocket accepts connections from any origin - CSWSH vulnerability

Open Rustix69 opened this issue 10 months ago • 3 comments

Describe the bug

The WebSocket upgrader in backend/controllers/websocket.go (lines 16-19) accepts connections from ANY origin by returning true in the CheckOrigin function. This disables CORS protection for WebSocket connections.

Security Impact

  • Cross-Site WebSocket Hijacking (CSWSH): Malicious websites can establish WebSocket connections to the backend
  • CSRF Attacks: Attackers can perform actions on behalf of authenticated users
  • Real-time Data Interception: Job status broadcasts can be intercepted by malicious sites
  • Session Hijacking: Attackers can access user-specific job updates
  • Data Leakage: Task information and sync statuses exposed to unauthorized origins

To Reproduce

  1. User logs into CCSync
  2. User visits malicious website https://evil.com in another tab
  3. Malicious site connects WebSocket to victim's CCSync backend
  4. Attacker receives all real-time job status updates
  5. Sensitive task information is exfiltrated

Expected behavior

The WebSocket handler should validate the origin against a whitelist of allowed origins and reject connections from unauthorized domains.

Location

  • File: backend/controllers/websocket.go
  • Lines: 16-19
  • Issue: CheckOrigin always returns true

Fix Required

Implement proper origin validation to only accept connections from configured frontend origins (FRONTEND_ORIGIN_DEV, FRONTEND_ORIGIN_PROD).

Rustix69 avatar Jan 23 '26 21:01 Rustix69

@its-me-abhishek I will be pushing a small fix for it soon.

Rustix69 avatar Jan 23 '26 21:01 Rustix69

seems to be fixed by #414

its-me-abhishek avatar Jan 24 '26 07:01 its-me-abhishek

@its-me-abhishek Hey sorry may be I hadnt took the latest pull

Rustix69 avatar Jan 24 '26 07:01 Rustix69