Skip to content

Bug: Member bulk-select is ungated (self + owner rows selectable) and removeMember has no self-removal backend guard #2043

Closed

Description

@yannickmonney

Area / route
Org settings → Members table. /dashboard/{org}/settings/organization. Frontend: services/platform/app/features/settings/organization/components/member-table.tsx. Backend: services/platform/convex/members/mutations.ts (removeMember).

Steps to reproduce

  1. Sign in as an org admin (not the owner) and open /dashboard/{org}/settings/organization.
  2. In the Members table, tick the row-select checkbox on your OWN row (and/or the owner row) plus other rows.
  3. Use the BulkDeleteBar footer to remove the selection.

Expected
Consistent with the single-row action menu, which hides Delete for self and owner (member-row-actions.tsx:73, visible: canManageMembers && !isViewingSelf && !isOwner):

  • The current-user row and the owner row should NOT be selectable for bulk-delete (per-row enableRowSelection predicate).
  • removeMember should reject self-removal at the backend (defense in depth), regardless of how the request is issued.

Actual

  • Bulk-select is rendered for every row with no gating. createSelectColumn<Member>() (member-table.tsx:94) has no getCanSelect/disabled predicate (see column-builders.tsx:316-354), and the table passes a bare boolean enableRowSelection (member-table.tsx:189). So the current-user row and the owner row are both selectable.
  • removeMember (members/mutations.ts:132-237) guards: unauthenticated (138), member-not-found (150), caller-is-admin (168), target-is-owner (172), legal-hold (192-201). It never compares authUser.userId === member.userId, so an admin can delete their OWN membership. The companion test file has no self-removal case, confirming the guard is absent.
  • Removing one's own row drops the RLS mirror (mutations.ts:211) and runs cascadeOnMemberRemoved (mutations.ts:214), which hard-deletes that user's userMemories + userPreferences + org-scoped TTS chunks (personalization_cascade.ts:58-65) — a self-lockout plus irreversible self-data erasure, with no confirmation tuned to self-removal.
  • The owner row is backend-protected (mutations.ts:172-174 throws "The organization owner cannot be removed"), so an owner included in a bulk batch partial-fails: the row stays and an error toast surfaces (the code comment at member-table.tsx:91-93 acknowledges this). That part is a UX/affordance defect, not a security hole.

Evidence (file:line)

  • services/platform/app/features/settings/organization/components/member-table.tsx:94 — createSelectColumn<Member>() with no predicate
  • services/platform/app/features/settings/organization/components/member-table.tsx:189 — bare enableRowSelection boolean
  • services/platform/app/components/ui/data-table/column-builders.tsx:316-354 — createSelectColumn renders a checkbox on every row, no getCanSelect
  • services/platform/app/features/settings/organization/components/member-row-actions.tsx:46,48,73 — single-row Delete gated !isViewingSelf && !isOwner
  • services/platform/convex/members/mutations.ts:132-237 — removeMember; no authUser.userId === member.userId check
  • services/platform/convex/lib/cascades/personalization_cascade.ts:58-65 — cascadeOnMemberRemoved hard-deletes the user's memories/preferences/TTS for the org
  • services/platform/convex/members/mutations.test.ts:107-230 — no self-removal test case

Notes

  • The fix pattern already exists in-repo: agents-table.tsx:298 passes enableRowSelection={(row) => ...} as a per-row predicate, and DataTable already types enableRowSelection?: boolean | ((row) => boolean) (data-table.tsx:186). Gate selection on row.original._id !== memberContext?.member?._id and row.original.role?.toLowerCase() !== 'owner'.
  • Add the backend guard in removeMember (e.g. throw if authUser.userId === member.userId) so the UI gate is enforced server-side, and add a regression test alongside the existing owner-guard test.
  • Severity is medium rather than high: the existing owner-guard means an org always retains its owner (no full org-orphaning), and self-removal is self-inflicted by an admin on their own row (not cross-user privilege escalation). The genuine harm is self-lockout, silent self-personalization erasure, and the UI/backend gating inconsistency.

Filed by an automated manual-review pass (live browser QA + a 25-agent code-grounded audit, each finding adversarially verified). Deduped against open issues (incl. #1972–#1999, settings/forms epic #1941–#1966, audit cluster #1842–#1846) and recently-closed issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    automatedbugpriority: mediumsecurityservice: platform

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions