fix(websocket): enforce auth, prevent provider hijack, and add consumer limits#345
fix(websocket): enforce auth, prevent provider hijack, and add consumer limits#345Akash504-ai wants to merge 1 commit into
Conversation
WalkthroughThe WebSocket server adds privilege-based access control via an ChangesWebSocket Authorization & Role Management
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
Poem
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Review rate limit: 0/1 reviews remaining, refill in 60 minutes.Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/server/websocket.ts`:
- Around line 115-116: isPrivileged currently only allows localhost (returns
isLocal) which blocks token-authenticated remote viewers because startMirror()
marks sockets as isConsumer and frame relay targets isConsumer sockets; update
isPrivileged to allow privileged access for sockets that are marked as consumers
in addition to local sockets (e.g., return isLocal || (ws as any).isConsumer or
consult the socket's consumer/auth flag). Apply the same change to the other
privilege checks referenced (the blocks around lines 139-142, 153-160, 229-244)
so that all checks allow isConsumer sockets the same way they allow isLocal.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: 99012c59-82e0-4828-9f37-87392019e9dd
📒 Files selected for processing (1)
src/server/websocket.ts
Addressed Issues:
Fixes # (security / stability issue in websocket server)
Description
This PR fixes multiple critical security and stability issues in the WebSocket server implementation.
Key Fixes:
Impact:
Screenshots/Recordings:
N/A (backend/security fix)
Functional Verification
Screen Mirror
Authentication
Basic Gestures
Modes & Settings
Advanced Input
Any other gesture or input behavior introduced:
Additional Notes:
src/server/websocket.tsChecklist
Summary by CodeRabbit
Security Improvements
Stability Improvements