-
Notifications
You must be signed in to change notification settings - Fork 0
security: replace JWT query parameter with one-time ticket for WebSocket auth #343
Copy link
Copy link
Labels
prio:highImportant, should be prioritizedImportant, should be prioritizedspec:securityDESIGN_SPEC Section 12 - Security & Approval SystemDESIGN_SPEC Section 12 - Security & Approval Systemtype:featureNew feature implementationNew feature implementation
Description
Problem
The WebSocket connection currently passes the JWT as a URL query parameter:
const url = `${getWsUrl()}?token=${encodeURIComponent(token)}`This exposes the bearer token in:
- nginx/proxy access logs (full URL including query string)
- Browser history
Refererheaders on any redirects- Server-side access logs
Flagged by 3 independent reviewers on PR #342 (Greptile, Gemini, CodeRabbit).
Solution
Implement a short-lived, single-use WS ticket exchange:
- Backend: Add
POST /api/v1/auth/ws-ticketendpoint that accepts a valid JWT and returns a single-use ticket (random token, ~30s TTL, stored in-memory or Redis) - Frontend: Before opening WebSocket, call the ticket endpoint, then connect with
?ticket=<ticket>instead of?token=<jwt> - Backend WS handler: Validate and consume the ticket on connect (single-use = delete after first use)
This ensures:
- No long-lived credentials in URLs/logs
- Ticket is useless if intercepted (single-use + short TTL)
- JWT remains in
Authorizationheader for REST calls only
Scope
- Backend: new endpoint + ticket store + WS handler changes
- Frontend:
web/src/stores/websocket.ts— replace direct JWT URL with ticket exchange inconnect() - The TODO comment at
websocket.ts:50-51documents this debt
Acceptance Criteria
- JWT never appears in WebSocket URL
- Ticket expires after 30 seconds or first use
- Ticket exchange requires valid JWT
- WebSocket connection fails gracefully if ticket exchange fails
- Existing WS reconnect logic works with ticket refresh
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
prio:highImportant, should be prioritizedImportant, should be prioritizedspec:securityDESIGN_SPEC Section 12 - Security & Approval SystemDESIGN_SPEC Section 12 - Security & Approval Systemtype:featureNew feature implementationNew feature implementation