Repository navigation
fix(auth): require organizationId to match the authenticated org in ORGANIZATION_MEMBER_REMOVE - #5106
Merged
Merged
Conversation
…RGANIZATION_MEMBER_REMOVE
pedrofrxncx
enabled auto-merge (squash)
July 23, 2026 16:41
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Source: bug — a cross-tenant authorization gap found while auditing the org-scoping pattern from #5104 (fail-closed org resolution).
ORGANIZATION_MEMBER_REMOVEis the sibling ofORGANIZATION_MEMBER_ADDandORGANIZATION_MEMBER_UPDATE_ROLE; both of those validate the targetorganizationIdagainst 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 inctx.organization(the path-resolved org). Sinceinput.organizationIdis optional and falls back toctx.organization?.idbut was never validated against it, any authenticated caller with remove-member permission in their own org could pass an arbitraryorganizationIdand remove a member from a completely unrelated org they have no membership in at all.Failure scenario + fix: Caller is a member of
org-awithORGANIZATION_MEMBER_REMOVEpermission there. They call the tool with{ organizationId: "org-b", memberIdOrEmail: "[email protected]" }.ctx.access.check()passes (checked againstorg-a), and the handler callsboundAuth.organization.removeMember({ organizationId: "org-b", ... })unchecked — removing a member fromorg-bdespite the caller having zero relationship to it. The fix adds the sameorganizationId !== ctx.organization?.idguard already used inmember-add.ts, failing closed with an error instead of proceeding. Addedmember-remove.test.tscovering both the rejected-mismatch and the legitimate same-org path.Reviewer command:
bun test apps/mesh/src/tools/organization/member-remove.test.tsLocal checks run:
bun run fmt(clean),bunx tsc --noEmitinapps/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
organizationIdto match the authenticated org inORGANIZATION_MEMBER_REMOVE. Mismatches now fail with an error; tests cover both rejection and valid paths.input.organizationId !== ctx.organization?.id.member-remove.test.tsfor mismatch rejection and same-org success.Written for commit 972502a. Summary will update on new commits.