Skip to content

fix(auth): require organizationId to match the authenticated org in ORGANIZATION_MEMBER_REMOVE - #5106

Merged
pedrofrxncx merged 1 commit into
mainfrom
fix/member-remove-cross-org-scope-w8
Jul 23, 2026
Merged

pedrofrxncx merged 1 commit into
mainfrom
fix/member-remove-cross-org-scope-w8

Conversation

@pedrofrxncx

@pedrofrxncx pedrofrxncx commented Jul 23, 2026 •

Copy link
Copy Markdown
Collaborator

Source: bug — a cross-tenant authorization gap found while auditing the org-scoping pattern from #5104 (fail-closed org resolution). ORGANIZATION_MEMBER_REMOVE is the sibling of ORGANIZATION_MEMBER_ADD and ORGANIZATION_MEMBER_UPDATE_ROLE; both of those validate the target organizationId against the caller's real authorization before acting (an explicit equality check in member-add, a target-org DB membership lookup in member-update-role), but member-remove never had either check.

Why a maintainer wants it: ctx.access.check() only verifies the caller's permission in ctx.organization (the path-resolved org). Since input.organizationId is optional and falls back to ctx.organization?.id but was never validated against it, any authenticated caller with remove-member permission in their own org could pass an arbitrary organizationId and remove a member from a completely unrelated org they have no membership in at all.

Failure scenario + fix: Caller is a member of org-a with ORGANIZATION_MEMBER_REMOVE permission there. They call the tool with { organizationId: "org-b", memberIdOrEmail: "[email protected]" }. ctx.access.check() passes (checked against org-a), and the handler calls boundAuth.organization.removeMember({ organizationId: "org-b", ... }) unchecked — removing a member from org-b despite the caller having zero relationship to it. The fix adds the same organizationId !== ctx.organization?.id guard already used in member-add.ts, failing closed with an error instead of proceeding. Added member-remove.test.ts covering both the rejected-mismatch and the legitimate same-org path.

Reviewer command: bun test apps/mesh/src/tools/organization/member-remove.test.ts

Local checks run: bun run fmt (clean), bunx tsc --noEmit in apps/mesh (clean), targeted test file above (2 pass). Full CI suite (lint, e2e) not run locally per repo guidance.


Summary by cubic

Fixes a cross-tenant auth gap by requiring organizationId to match the authenticated org in ORGANIZATION_MEMBER_REMOVE. Mismatches now fail with an error; tests cover both rejection and valid paths.

  • Bug Fixes
    • Add equality check: reject when input.organizationId !== ctx.organization?.id.
    • Prevents users authorized in one org from removing members in another.
    • Add member-remove.test.ts for mismatch rejection and same-org success.

Written for commit 972502a. Summary will update on new commits.

Review in cubic

@pedrofrxncx
pedrofrxncx enabled auto-merge (squash) July 23, 2026 16:41
@pedrofrxncx
pedrofrxncx merged commit 8cfdc58 into main Jul 23, 2026
14 checks passed
@pedrofrxncx
pedrofrxncx deleted the fix/member-remove-cross-org-scope-w8 branch July 23, 2026 16:47
decocms Bot pushed a commit that referenced this pull request Jul 23, 2026
PR: #5106 fix(auth): require organizationId to match the authenticated org in ORGANIZATION_MEMBER_REMOVE
Bump type: patch

- decocms (apps/mesh/package.json): 4.108.3 -> 4.108.4

Deploy-Scope: server
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant