fix(groups): guard member mutations against stale roles - #626
Merged
junhoyeo merged 1 commit intoMay 30, 2026
Merged
Conversation
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
There was a problem hiding this comment.
1 issue found across 4 files
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
Validation * Validation tier: Tier 3 - High-Risk Runtime / security-sensitive group membership permission mutation. * bun run --cwd packages/frontend test __tests__/api/groupMemberDeleteRoute.test.ts __tests__/api/groupMemberRoleRoute.test.ts __tests__/api/groupsPayloadGuard.test.ts: PASS, 16/16 tests. * cd packages/frontend && bun run test __tests__/api/group*.test.ts __tests__/lib/groupHelpers.test.ts: PASS, 50/50 tests. * bun run --cwd packages/frontend lint -- 'src/app/api/groups/[slug]/members/route.ts' 'src/app/api/groups/[slug]/members/[userId]/role/route.ts' __tests__/api/groupMemberDeleteRoute.test.ts __tests__/api/groupMemberRoleRoute.test.ts __tests__/api/groupsPayloadGuard.test.ts: PASS, no output. * git diff --check: PASS. * git diff --cached --check: PASS. * Ledger: not applicable - not required for selected validation tier/change family. * Version: not applicable - not required for selected validation tier/change family. * Not run: full frontend build/coverage - not required for selected validation tier; targeted group route tests and touched-file lint covered this change. Rollback * git revert HEAD
IvGolovach
force-pushed
the
codex/group-member-race-safe-20260528
branch
from
May 28, 2026 18:40
657514b to
899a602
Compare
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.
Summary
Why
Group member mutations previously authorized from membership state loaded before the write. A concurrent demotion, removal, or target role change could make that authorization stale by the time the mutation executed. This PR moves the decisive actor/target role checks into the mutation boundary so group admins cannot accidentally act with stale privileges and owner invariants are preserved under concurrent changes.
Diff scope
packages/frontend/src/app/api/groups/[slug]/members/route.tspackages/frontend/src/app/api/groups/[slug]/members/[userId]/role/route.tspackages/frontend/__tests__/api/groupMemberDeleteRoute.test.tspackages/frontend/__tests__/api/groupMemberRoleRoute.test.tsBranch integrity
mainc21f0f533205ad63e9154666c294bb789d2415c9IvGolovach:codex/group-member-race-safe-20260528657514bf3bc979826d24ce9607d8a2b4c8e3585aorigin/main:1 ahead / 0 behind657514bf3bc979826d24ce9607d8a2b4c8e3585a fix(groups): guard member mutations against stale rolesValidation
bun run test __tests__/api/group*.test.ts __tests__/lib/groupHelpers.test.tsfrompackages/frontend: PASS, 49 tests passed.bun x eslint 'src/app/api/groups/[slug]/members/route.ts' 'src/app/api/groups/[slug]/members/[userId]/role/route.ts' __tests__/api/groupMemberDeleteRoute.test.ts __tests__/api/groupMemberRoleRoute.test.tsfrompackages/frontend: PASS, no output.git diff --check origin/main...HEAD: PASS, no output.git status --short --untracked-files=all: PASS, clean worktree.Runtime safety
Migration notes
Not applicable - no database migration or schema change.
Rollback plan
Rollback: revert this PR. DB downgrade: not applicable. Data repair: not applicable. Operational caveats: none known.
Known residual risks
Summary by cubic
Prevents stale-role race conditions in group member delete and role update by rechecking and row-locking actor/target memberships inside the transaction with a deterministic lock order. This blocks actions with outdated privileges and preserves owner safety.
canManageGroupRole, return 403 on stale roles and 404 when missing; preserve private-group 404 behavior.Written for commit 899a602. Summary will update on new commits.
Review in cubic