Repository navigation
fix(teams): stop console developers from changing membership roles - #14097
Conversation
Console organization developer is treated as privileged when X-Appwrite-Organization adds bare org roles. That let a confirmed developer PATCH membership roles to owner. Role changes on the console project now require the team owner role or an API key; admin-mode privileged users on customer projects are unchanged. Reported via Help Scout HS 1468593 (same class as HS 1467479). Co-authored-by: Jake Barnby <[email protected]>
✨ Benchmark resultsComparing
Per-scenario breakdown & investigation detailsMetrics below reflect the current branch (after). Δ P95 compares against the base.
Top API waits (after)
|
🟢 Tier S · Ready to merge
This change restricts console membership role updates and invitations to team owners or API keys, while retaining privileged-user access on customer projects. End-to-end coverage checks developer denials and owner success with an organization header for both operations. Latest changes: The latest commits add invitation tests for developer denial and owner success with the organization header.
📂 Walkthrough · 3
✅ Fixed since the last review · 1
Reviewed the commits since |
…header The membership create authorization change had no POST regression. A console developer with X-Appwrite-Organization still cannot invite as owner; the owner can still send a pending developer invite. Co-authored-by: Jake Barnby <[email protected]>
Bring in main 537fa27 (#14097 console membership role changes and invitations need the team owner or an API key; #14098 Local build workers attach only the project's app-<projectId> subdirectory of the builds volume) so the PR is mergeable again. Conflicts: - tests/unit/Deployment/DeploymentsTest.php: kept both sides. Imports are the union (orchestrator Jobs/exceptions for the submission-recovery tests plus Model\Volume for the volume-isolation tests). The branch's submission tests and Memory-adapter helpers stay, followed by main's two Local build mount tests and their withLocalBuilds() helper; buildPayload() takes main's projectId parameter (auto-merged). Adaptations: none. Main's changes touch no database APIs; composer.json and composer.lock are unchanged, database stays at e8cb1af9a. Co-Authored-By: Claude Opus 5.5 <[email protected]>
What does this PR do?
Fixes a privilege-escalation on the console project (Help Scout HS 1468593).
A confirmed organization member with the developer role could
PATCH /v1/teams/{teamId}/memberships/{membershipId}with{"roles":["owner"]}andX-Appwrite-Organization: {teamId}and receive HTTP 200, promoting themselves or changing another membership. The same request without that header correctly returned 401 (User is not allowed to modify roles).X-Appwrite-Mode: adminis not required and is rejected on console.Memberships/Updatetreated$user->isPrivileged()as sufficient to change roles.User::isPrivilegedincludesROLE_DEVELOPER. When the organization header applies, console requests add the org membership roles as baredeveloper/admin/ownerroles, so a developer became “privileged” and skipped the team-owner check.This is the same class as HS 1467479 (which stopped the organization header from selecting a team on non-
organizationroutes). That layer is still useful, butUpdate.phpremained a second bypass if those bare roles are present.Fix (narrow, memberships only): on the console project, changing membership roles or sending invitations now requires the team owner role or an API key.
isPrivileged/ organization developer is no longer enough. Customer-project admin mode, API keys, and team owners are unchanged. GlobalisPrivilegedsemantics are unchanged — other call sites (storage, databases, privacy) still treat developer as privileged for project-admin APIs.Credits: reported by Yoni Gg / @Jgarcg40. Prior related report: 정민기 / @jungmingi-lab (HS 1467479).
Test Plan
TeamsConsoleClientTest::testConsoleDeveloperCannotUpdateMembershipRoles:X-Appwrite-Organizationcannot self-promote toowner(401).ownerroles (401).developer.testTeamRoutesIgnoreOrganizationHeaderandtestUpdateTeamMembershipRolesremain.TeamsCustomClientTest/TeamsCustomServerTeststill cover owner and API-key role updates on non-console projects.Related PRs and Issues
Checklist