{"id":"XE-13242","kind":"bounty","visibility":"public","source":"github","source_repo":"xeprotocol/xe","source_ref":"370","source_url":"https://github.com/xeprotocol/xe/issues/370","reporter_id":2,"title":"[Desk] Removing a member's roles leaves sessions, invites, passkeys and TOTP sign-in live, and dual-cookie browsers split reporter accounts","area":"other","claimed_tier":null,"assessed_tier":null,"verdict":null,"duplicate_of":null,"tracked":false,"internal_ref":"","internal_url":null,"status":"triaging","closed_reason":null,"github_state":"open","disclosed_at":null,"award_xe":null,"award_approved":false,"paid_ref":"","created_at":"2026-11-14T20:42:03.020120+00:00","updated_at":"2026-11-20T00:17:10.357759+00:00","source_created_at":"2026-11-11T10:32:55+00:00","told_at":"2026-11-20T00:15:43+00:00","status_changed_at":"2026-11-20T00:15:29.797613+00:00","url":"https://bounty.xe.network/XE-13242","body":"### Summary\n\nIn `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:\n\n1. **Roleless `User` (`u.roles == []`) retains live sessions, invites, passkey login, and TOTP login (Medium)**:\n   - `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`.\n   - `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)`.\n   - 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.\n2. **Dual-cookie browser (`desk_session` + `desk_reporter`) breaks reporter routes and creates split accounts on identity linking**:\n   - 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`).\n   - 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`.\n\n### Rule\n\nA `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.\n\n### Proposed Fix\n\nReady-to-merge patch and regression tests submitted in https://github.com/xeprotocol/desk/pull/1.\n","patch_refs":[],"thread":[{"id":12913,"source":"github","source_ref":"7026050067","author":"Joseph Denne","team":true,"body":"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.","created_at":"2026-11-20T00:15:43+00:00"}]}