Skip to content

Commit 4c1bdd1

Browse files
fix(api): use requester's workspace role for project member role updates (GHSA-x63v-p7wc-47x4) (#9014)
is_workspace_admin in ProjectMemberViewSet.partial_update was derived from the target member's workspace role, not the requester's. When the target happened to be a workspace admin, all three project-role guards (L231/238/247) were bypassed regardless of who was making the request, allowing a non-admin requester to re-role a workspace admin's project membership. Compute is_workspace_admin from the requester instead and keep the target's workspace role under a distinct name for the existing new-role-vs-workspace-role cap.
1 parent ff21e53 commit 4c1bdd1

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

apps/api/plane/app/views/project/member.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -206,11 +206,15 @@ def retrieve(self, request, slug, project_id, pk):
206206
def partial_update(self, request, slug, project_id, pk):
207207
project_member = ProjectMember.objects.get(pk=pk, workspace__slug=slug, project_id=project_id, is_active=True)
208208

209-
# Fetch the workspace role of the project member
210-
workspace_role = WorkspaceMember.objects.get(
209+
# Fetch the target's workspace role (used to cap the new project role)
210+
target_workspace_role = WorkspaceMember.objects.get(
211211
workspace__slug=slug, member=project_member.member, is_active=True
212212
).role
213-
is_workspace_admin = workspace_role == ROLE.ADMIN.value
213+
# Fetch the requester's workspace role to decide if they may bypass project-role checks
214+
requester_workspace_role = WorkspaceMember.objects.get(
215+
workspace__slug=slug, member=request.user, is_active=True
216+
).role
217+
is_workspace_admin = requester_workspace_role == ROLE.ADMIN.value
214218

215219
# Check if the user is not editing their own role if they are not an admin
216220
if request.user.id == project_member.member_id and not is_workspace_admin:
@@ -251,7 +255,7 @@ def partial_update(self, request, slug, project_id, pk):
251255
)
252256

253257
# Cannot assign a role higher than the target's workspace role
254-
if workspace_role in [5] and new_role in [15, 20]:
258+
if target_workspace_role in [5] and new_role in [15, 20]:
255259
return Response(
256260
{"error": "You cannot add a user with role higher than the workspace role"},
257261
status=status.HTTP_400_BAD_REQUEST,

0 commit comments

Comments
 (0)