Files
ServerKit/backend
Juan DenisandClaude Fable 5 fd825276b9 fix(sockets): authorize socket connections by role; gate terminal streams
The Socket.IO connect handler only checked that the JWT decoded — it never
confirmed the account still exists or is active, and recorded no identity. The
generic join_room and subscribe_terminal handlers then performed no
authorization, so a read-only viewer (or a deactivated account with an
unexpired token) could attach to a live PTY stream room and watch a privileged
shell.

- connect: resolve the JWT identity to a live, active User and stash
  {user_id, role} per sid; reject missing/deactivated accounts.
- subscribe_terminal and join_room (for _terminal: rooms): require
  admin/developer, matching the @developer_required on terminal creation.
- disconnect: drop the per-sid identity record.

Job-progress and cloudflared-login streaming (non-terminal server rooms) are
unaffected — that data is already reachable over REST by any authenticated user.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-06-12 01:33:44 -04:00
..