Skip to content

fix(organization): require an organization owner to transfer a project (appwrite:appwrite:alert#4623) - #15178

Merged
ChiragAgg5k merged 3 commits into
mainfrom
fix/transfers-owner-only
Nov 10, 2026
Merged

ChiragAgg5k merged 3 commits into
mainfrom
fix/transfers-owner-only

Conversation

@claudear

@claudear claudear commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

What

appwrite:appwrite:alert#4623 — the project transfer routes gated only on the projects.write scope, so a non-owner organization member could move a project out of the organization and defeat the owner-only rule that PATCH /v1/projects/:projectId/team enforces.

projects.write is not an owner-only scope. app/config/roles.php:91 puts it in the shared $admins array that ROLE_ADMIN and ROLE_DEVELOPER both receive verbatim, and app/config/scopes/organization.php:10 exposes it as an organization API key scope. app/controllers/shared/api.php:557 is the only gate on the transfer routes and it is purely scope-based, so a team-wide developer or admin member — or a CI organization key — could create a transfer for any project in the organization and claim it into an organization they control. The same move through the sibling endpoint is refused for exactly those callers.

Changes

  • Owner required on create, delete and claim. The owner lookup that was private to Projects/Http/Projects/Team/Update.php moves onto Appwrite\Utopia\Database\Documents\User as isOwner(), where it reads as behavior on the entity, and both modules call it. Transfers/Create.php and Transfers/Delete.php require a confirmed owner membership of the sending organization; Transfers/Status/Update.php requires one of the claiming organization. The team endpoint keeps the exact behavior it had.
  • Organization API keys may not transfer projects. This is the explicit decision the report asked for. A key carries no membership, so the ported check refuses it without a special case. Keys were already unable to use the team endpoint at all (it needs a user membership), so this makes the two routes agree rather than leaving keys stronger than human admins. The transfer routes' auth: lists are unchanged — AuthType::ORGANIZATION only marks the X-Appwrite-Organization header, it never declared key support.
  • The secret stays with the owners. The secret is the capability to move the project, and projects.read reaches both GET /v1/organization/transfers and GET /v1/organization/transfers/:transferId. Without this, a developer could read back a secret an owner had created and claim the project into an organization of their own — the same escalation, one step removed. Both routes now return the secret only to a confirmed owner of the sending organization; other organizations already never received it.
  • Console. canTransferProject now requires access.isOwner, so the transfer card and the destination list stop offering an action that would 401. The blocked-state copy and its he/ja dictionary entries were updated with it.

Tests

testProjectTransferRequiresOwner in tests/e2e/Services/Organization/TransfersBase.php is the regression, written before the fix and failing against the old code. It invites a confirmed developer and a confirmed admin into the sending organization and a developer into the claiming one, then asserts each is refused on create, delete and claim, that neither can read the secret back from the list or the get route, that the project has not moved, and that the actual owner can still claim it.

The other direction — an organization API key — is not covered by an e2e test because this repository has no endpoint that mints one; organization keys are created by an edition on top of it.

The console-role security probe in tests/e2e/Security does not catch this class of bug by construction: its applies() returns early when the route's scope is in the developer's scope set, which projects.write is. Worth a follow-up, but not folded in here.

Verification

  • composer lint and PHPStan clean on every touched PHP file.
  • The e2e suite could not be run in the authoring sandbox: the Appwrite image build fails on an unrelated apk add 'ca-certificates>=20261020-r0' constraint in the composer:2 stage, so the Organization lane in CI is the run that matters here.

🤖 Generated with Claude Code

abnegate and others added 3 commits November 2, 2026 10:19
…ect transfer

The project transfer routes gated only on the `projects.write` scope, which
`app/config/roles.php` hands to the organization-wide `developer` and `admin`
roles and `app/config/scopes/organization.php` exposes to organization API
keys. Moving a project with `PATCH /v1/projects/:projectId/team` needs a
confirmed `owner` membership on both organizations, so the newer transfer
routes let a non-owner member — or a CI organization key — move any project in
the organization into one they control and defeat that rule.

Hoist the owner lookup from the private method on `Projects/.../Team/Update.php`
onto `User`, where it reads as behavior on the entity, and require it on the
sending organization in `Transfers/Create.php` and `Transfers/Delete.php` and
on the claiming organization in `Transfers/Status/Update.php`. Organization API
keys carry no membership, so the same check refuses them.

Co-Authored-By: Claude Opus 5 <[email protected]>
…tion owners

The secret is the capability to move the project: anyone holding it can claim
the project into an organization they own. `projects.read` reaches both the
list and the get route, so a developer or admin member could read back a
secret an owner had created and claim the project into an organization of
their own, which is the same escalation the owner-only gate on create and
claim refuses.

Return the secret only to a confirmed owner of the organization that owns the
project. Other organizations already never receive it.

Co-Authored-By: Claude Opus 5 <[email protected]>
…only

The API now requires the owner role on both organizations, so a developer or
admin who was offered the card got a 401 from it, and the destination list
offered organizations they could not claim into.

Co-Authored-By: Claude Opus 5 <[email protected]>
@luxor-code-review

luxor-code-review Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

Review complete. No blocking issues — approved ✅; 2 nitpicks below.

🧹 Nitpicks (2) — 🟢 2 low
  • 🟢 Update SDK descriptions of the other transfer routes (Create.php:55) — This PR adds an owner-only rule to all transfer routes but only updated the SDK description heredocs on Get.php and XList.php.
  • 🟢 Stale docstring still says destination role must manage projects (project-transfers.ts) — The docstring above useTransferDestinations in apps/console/src/lib/react-query/hooks/project-transfers.ts (line 53) still says "the member's role must manage projects there", which was the pre-change rule.

This PR introduces project transfers between organizations: new HTTP actions under Modules/Organization/Http/Transfers/ that create transfer requests with secrets, resolve claimants, and apply the move through Projects/Team/Update.php, which now reuses a shared User::isOwner() membership check. The console transfer card is gated by an updated canTransferProject access check, with i18n copy updated in he and ja dictionaries. E2E coverage is added in TransfersBase.php. Two minor documentation-consistency issues were noted; the authorization and secret-redaction paths were verified as sound.

Files Change
src/Appwrite/Platform/Modules/Organization/Http/Transfers/* New transfer CRUD and status-update actions with owner checks and secret redaction
src/Appwrite/Platform/Modules/Projects/Http/Projects/Team/Update.php, src/Appwrite/Utopia/Database/Documents/User.php Shared isOwner() helper replacing the private membership check
apps/console/src/components/.../TransferProjectCard.tsx, apps/console/src/lib/console-access-checks.ts, i18n he/ja dictionaries Console transfer gating and copy updated for owner-only rule
tests/e2e/Services/Organization/TransfersBase.php E2E coverage for the transfer flow

Reviewed commit: 0286736

@appwrite

appwrite Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

New Console

Project ID: new-console

Sites (1)
Site Status Logs Preview QR
 New Console
new-console
Ready Ready View Logs Preview URL QR Code

Tip

Sites support three domain rule types: Active deployment, Git branch, and Redirect

@ghost

ghost commented Nov 2, 2026 •

Copy link
Copy Markdown

🟢 Tier S · Ready to merge

The transfer endpoints now require confirmed organization ownership to create or delete transfer links, claim a project, or retrieve its secret. The shared owner check is also used by the project-team endpoint, and the Console gate and regression coverage reflect the owner-only rule.

Verdict New comments Fixed Still open
✅ Approved 0 0 0
📂 Walkthrough · 12
File Change
apps/console/src/components/pages/projects/$projectId/settings/_components/TransferProjectCard.tsx Updates the blocked-state message to say project transfers are owner-only.
apps/console/src/lib/console-access-checks.ts Gates transfer actions on organization ownership rather than project-write scope.
apps/console/src/lib/i18n/dictionaries/he/project-misc.ts Updates the Hebrew owner-only transfer message.
apps/console/src/lib/i18n/dictionaries/ja/project-misc.ts Updates the Japanese owner-only transfer message.
src/Appwrite/Platform/Modules/Organization/Http/Transfers/Create.php Requires a confirmed owner of the sending organization to create a transfer.
src/Appwrite/Platform/Modules/Organization/Http/Transfers/Delete.php Requires a confirmed owner of the sending organization to delete a transfer.
src/Appwrite/Platform/Modules/Organization/Http/Transfers/Get.php Redacts the transfer secret from non-owners of the sending organization.
src/Appwrite/Platform/Modules/Organization/Http/Transfers/Status/Update.php Requires a confirmed owner of the claiming organization.
src/Appwrite/Platform/Modules/Organization/Http/Transfers/XList.php Returns transfer secrets in the sender's organization only to owners.
src/Appwrite/Platform/Modules/Projects/Http/Projects/Team/Update.php Uses the shared User owner check while preserving the existing transfer rule.
src/Appwrite/Utopia/Database/Documents/User.php Adds a confirmed-membership owner check to the User document.
tests/e2e/Services/Organization/TransfersBase.php Adds E2E coverage for non-owner transfer denials, secret redaction, and owner claiming.

Reviewed 0286736 · Details · Comment @hansi-codes review to re-run, or mention @hansi-codes with a question.

@pkg-pr-new

pkg-pr-new Bot commented Nov 2, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/appwrite/appwrite/@appwrite.io/console@15178

commit: 0286736

@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

@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown

Security rules

No new WARNING or ERROR findings from security rules.

6 existing findings tracked in .semgrep/baseline.json
  • php.appwrite.guest-write-without-abuse-limit (3)
  • php.appwrite.secret-compare-timing (1)
  • php.appwrite.weak-secret-env-default (2)

Posted by Checks / Rules. Re-runs update this comment in place. Rule details and baseline: .semgrep/README.md.

@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown

✨ Benchmark results

Comparing main (before) → fix/transfers-owner-only (after).

Metric Before After Change
🚀 Requests/sec 168.93 198.32 🟢 +17.4%
⏱️ Latency P50 101.35 ms 89.17 ms 🟢 -12%
⏱️ Latency P95 245.49 ms 204.53 ms 🟢 -16.7%
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 89.17 204.53 12,540 198.32 -40.96
Account 152.31 301.87 660 11.1 -65.24
TablesDB 88.2 162.95 6,820 110.34 -21.84
Storage 79.42 188.18 3,300 55.11 -25.73
Functions 115.85 238.31 1,760 30.34 -72.82

Top API waits (after)

API request Max wait (ms)
storage.buckets.create 452.89
functions.create 447.19
account.name.update 407.65
storage.files.create 368.73
functions.variables.update 353.93

@ChiragAgg5k
ChiragAgg5k merged commit 7a769f6 into main Nov 10, 2026
77 checks passed
ChiragAgg5k added a commit that referenced this pull request Nov 12, 2026
fix(organization): require an organization owner to transfer a project (appwrite:appwrite:alert#4623)

(cherry picked from commit 7a769f6)
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.

3 participants