Bounty
XE-13242 · Bounty

[Desk] Removing a member's roles leaves sessions, invites, passkeys and TOTP sign-in live, and dual-cookie browsers split reporter accounts

Triaging xe#370 filed 2026-11-11 10:32 UTC by Khanhtnq

Report

Summary

In xeprotocol/desk@ab9df7f, auth.resolve (desk/auth.py:726) treats a User with roles == [] as no longer a team member (# no roles, no team member), and users.set_roles(..., []) (desk/services/users.py:60) revokes agent tokens when a member leaves the team. However, six authentication/credential paths still treat a roleless User (u.active and u.roles == []) as an active team member, and browsers holding both desk_session and desk_reporter cookies fail to resolve their reporter session across reporter routes and UI pages:

  1. Roleless User (u.roles == []) retains live sessions, invites, passkey login, and TOTP login (Medium):
    • users.set_roles (desk/services/users.py:56-62) does not acquire auth.member_lock(db, u.id) before writing u.roles, does not delete existing Session rows, and does not call auth.drop_invites(db, u.id) when not u.roles.
    • auth.session_from_request, auth.consume_invite, auth.passkey_begin_login, auth.passkey_finish_login (desk/auth.py:167, 406, 599, 647), and authn.totp_login (desk/api/authn.py:131) check u.active without bool(u.roles).
    • Moreover, a stale desk_session belonging to a roleless User causes auth.resolve (L724-728) to return Auth(Principal(), session=None) early without falling through to reporter_session_from_request, locking that browser out of its reporter session until cookies are cleared.
  2. Dual-cookie browser (desk_session + desk_reporter) breaks reporter routes and creates split accounts on identity linking:
    • While rapi.logout (desk/api/reporter.py:388, XE-2101) explicitly calls auth.reporter_session_from_request(db, request) when who.session is not None, every other route in desk/api/reporter.py and desk/ui.py:128 reads who.reporter directly (which is None whenever who.session is present, per test_db.py:3904).
    • Consequently, in a browser holding both cookies (with valid team CSRF token), xe_login (rsvc.from_xe(..., link_to=who.reporter)) and email_start (_email_link) treat the signed-in reporter as signed out and silently create a separate duplicate Reporter account instead of linking to the browser's reporter account, while /v1/reporter/me returns {"reporter": null} and /payout, /tickets, /auth/github/link, /auth/discord/link, and /sessions/revoke-others fail with 401.

Rule

A User with roles == [] is not a team member on any session, invite, passkey, or TOTP path, and a browser holding both desk_session and desk_reporter resolves its reporter session on reporter routes and UI pages while deps.current retains the team principal and team CSRF check.

Proposed Fix

Ready-to-merge patch and regression tests submitted in https://github.com/xeprotocol/desk/pull/1.

Thread

Joseph Denneteam2026-11-20 00:15 UTCgithub

Thanks for the report. We have read it against the current code and it is being handled. The assessment and any award follow the fix.