Skip to content

fix(teams): stop console developers from changing membership roles - #14097

Merged
abnegate merged 2 commits into
mainfrom
cursor/membership-role-privilege-a3ce
Oct 5, 2026
Merged

abnegate merged 2 commits into
mainfrom
cursor/membership-role-privilege-a3ce

Conversation

@abnegate

@abnegate abnegate commented Oct 4, 2026 •

Copy link
Copy Markdown
Member

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"]} and X-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: admin is not required and is rejected on console.

Memberships/Update treated $user->isPrivileged() as sufficient to change roles. User::isPrivileged includes ROLE_DEVELOPER. When the organization header applies, console requests add the org membership roles as bare developer/admin/owner roles, 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-organization routes). That layer is still useful, but Update.php remained 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. Global isPrivileged semantics 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

  • Added TeamsConsoleClientTest::testConsoleDeveloperCannotUpdateMembershipRoles:
    • Confirmed console developer + X-Appwrite-Organization cannot self-promote to owner (401).
    • Same developer cannot change another membership’s roles (401).
    • Same developer cannot invite a member with owner roles (401).
    • Organization owner with the same header can still update roles (200); persisted roles stay developer.
    • Organization owner with the same header can still send a pending developer invite (201).
  • Existing testTeamRoutesIgnoreOrganizationHeader and testUpdateTeamMembershipRoles remain.
  • TeamsCustomClientTest / TeamsCustomServerTest still cover owner and API-key role updates on non-console projects.

Related PRs and Issues

  • Help Scout HS 1468593
  • Same class as HS 1467479

Checklist

  • Have you read the Contributing Guidelines on issues?
  • If the PR includes a change to an API's metadata (desc, label, params, etc.), does it also include updated API specs and example docs?
Open in Web Open in Cursor 

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]>
@github-actions

github-actions Bot commented Oct 4, 2026 •

Copy link
Copy Markdown

✨ Benchmark results

Comparing main (before) → cursor/membership-role-privilege-a3ce (after).

Metric Before After Change
🚀 Requests/sec 196.84 193.8 ⚪ -1.5%
⏱️ Latency P50 87.02 ms 90.06 ms ⚪ +3.5%
⏱️ Latency P95 209.42 ms 205.27 ms ⚪ -2%
Per-scenario breakdown & investigation details

Metrics below reflect the current branch (after). Δ P95 compares against the base.

Scenario P50 (ms) P95 (ms) Requests RPS Δ P95 (ms)
API total 90.06 205.27 12,483 193.8 -4.14
Account 163.33 315.32 657 10.87 -13.31
TablesDB 86.95 162.29 6,789 108.43 +5.23
Storage 83.96 183.32 3,285 53.75 -3.77
Functions 126.31 247.23 1,752 29.33 -17.18

Top API waits (after)

API request Max wait (ms)
account.prefs.update 424.84
account.name.update 399.82
functions.variables.create 380.58
functions.create 358.51
storage.files.create 350.54

@abnegate
abnegate marked this pull request as ready for review October 5, 2026 04:20
@ghost

ghost commented Oct 5, 2026 •

Copy link
Copy Markdown

🟢 Tier S · Ready to merge

The added tests address the outstanding invitation coverage finding, and no defects were found in the new changes.

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.

Verdict New comments Fixed Still open
✅ Approved 0 1 0
📂 Walkthrough · 3
File Change
src/Appwrite/Platform/Modules/Teams/Http/Memberships/Create.php Require team ownership or API-key access for console invitations.
src/Appwrite/Platform/Modules/Teams/Http/Memberships/Update.php Exclude bare privileged organization roles from console role-update authorization.
tests/e2e/Services/Teams/TeamsConsoleClientTest.php Cover developer update and invitation denials, plus owner success with an organization header.
✅ Fixed since the last review · 1
  • Add coverage for the console invitation restriction · src/Appwrite/Platform/Modules/Teams/Http/Memberships/Create.php:268

Reviewed the commits since 61c1f6e · Details · Comment @hansi-codes review to re-run, or mention @hansi-codes with a question.

@ghost ghost left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Tier A · Looks good to merge. Summary

…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]>

@ghost ghost left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Tier S · Looks good to merge. Summary

@abnegate
abnegate merged commit 840b537 into main Oct 5, 2026
50 checks passed
@abnegate
abnegate deleted the cursor/membership-role-privilege-a3ce branch October 5, 2026 04:53
abnegate added a commit that referenced this pull request Oct 5, 2026
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]>
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.

2 participants